Module: Easyfire::Renders::Helpers

Included in:
Model, Service
Defined in:
lib/easyfire/renders/helpers.rb

Constant Summary collapse

@@java_data_types =
{
  String: "String",
  Long: "Long",
  Boolean: "Boolean"
}
@@swift_data_types =
{
  String: "String?",
  Long: "CLong?",
  Boolean: "Bool?"
}
@@java_defaults =
{
  String: "\"\"",
  Long: "0L",
  Boolean: "false"
}
@@swift_defaults =
{
  String: "\"\"",
  Long: "0",
  Boolean: "false"
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#base_packageObject

Returns the value of attribute base_package.



5
6
7
# File 'lib/easyfire/renders/helpers.rb', line 5

def base_package
  @base_package
end

#versionObject

Returns the value of attribute version.



5
6
7
# File 'lib/easyfire/renders/helpers.rb', line 5

def version
  @version
end

Instance Method Details

#extract_spec(spec) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/easyfire/renders/helpers.rb', line 47

def extract_spec(spec)
  @spec = spec
  @name = spec.model_name.to_s
  @class_name_ef = spec.model_name.to_s + "EF"
  @service_class = spec.model_name.to_s + "ServiceEF"
  @object_name_ef = spec.model_name.to_s.uncapitalize + "EF"
  @collection_name = spec.model_name.to_s.underscore
  @declaration = "#{@class_name_ef} #{@object_name_ef}"
  @description = spec.description
  @attributes = spec.attributes
  @belongs_to = spec.associations
  @parents = spec.parents
end

#generate(template) ⇒ Object



61
62
63
# File 'lib/easyfire/renders/helpers.rb', line 61

def generate(template)
  ERB.new(template).result(binding)
end

#java_default_value(data_type) ⇒ Object



39
40
41
# File 'lib/easyfire/renders/helpers.rb', line 39

def java_default_value(data_type)
  @@java_defaults[data_type] || "null"
end

#swift_default_value(data_type) ⇒ Object



43
44
45
# File 'lib/easyfire/renders/helpers.rb', line 43

def swift_default_value(data_type)
  @@swift_defaults[data_type]
end

#type_to_java_value(data_type) ⇒ Object



31
32
33
# File 'lib/easyfire/renders/helpers.rb', line 31

def type_to_java_value(data_type)
  @@java_data_types[data_type] || data_type.to_s
end

#type_to_swift_value(data_type) ⇒ Object



34
35
36
# File 'lib/easyfire/renders/helpers.rb', line 34

def type_to_swift_value(data_type)
  @@swift_data_types[data_type]
end