Class: Hecks::Domain::DomainBuilder::Attribute
- Inherits:
-
Object
- Object
- Hecks::Domain::DomainBuilder::Attribute
- Defined in:
- lib/domain_builder/attribute.rb
Instance Attribute Summary collapse
-
#object_name ⇒ Object
readonly
Returns the value of attribute object_name.
- #type ⇒ Object
Instance Method Summary collapse
- #==(other) ⇒ Object
- #copy(new_values = {}) ⇒ Object
- #domain_module ⇒ Object
- #domain_reference? ⇒ Boolean
-
#initialize(string) ⇒ Attribute
constructor
A new instance of Attribute.
- #list? ⇒ Boolean
- #name ⇒ Object
- #primitive? ⇒ Boolean
- #reference? ⇒ Boolean
- #referenced_object ⇒ Object
Constructor Details
#initialize(string) ⇒ Attribute
Returns a new instance of Attribute.
8 9 10 11 |
# File 'lib/domain_builder/attribute.rb', line 8 def initialize(string) @string = string @object_name = object_name end |
Instance Attribute Details
#object_name ⇒ Object (readonly)
Returns the value of attribute object_name.
6 7 8 |
# File 'lib/domain_builder/attribute.rb', line 6 def object_name @object_name end |
#type ⇒ Object
21 22 23 24 |
# File 'lib/domain_builder/attribute.rb', line 21 def type return @type if @type @string.split(":").last.delete("[").delete("]").camelize end |
Instance Method Details
#==(other) ⇒ Object
55 56 57 58 59 60 |
# File 'lib/domain_builder/attribute.rb', line 55 def ==(other) return false if other.name != name return false if other.type != type return false if other.domain_module != domain_module return true end |
#copy(new_values = {}) ⇒ Object
31 32 33 34 35 |
# File 'lib/domain_builder/attribute.rb', line 31 def copy(new_values={}) result = self.class.new(@string) result.type = new_values[:type] if new_values[:type] result end |
#domain_module ⇒ Object
26 27 28 29 |
# File 'lib/domain_builder/attribute.rb', line 26 def domain_module return unless @string.include?("::") @string.split("::").first.split(":").last.camelize end |
#domain_reference? ⇒ Boolean
41 42 43 |
# File 'lib/domain_builder/attribute.rb', line 41 def domain_reference? @string.include?('::') end |
#list? ⇒ Boolean
13 14 15 |
# File 'lib/domain_builder/attribute.rb', line 13 def list? @string.include?("[") end |
#name ⇒ Object
17 18 19 |
# File 'lib/domain_builder/attribute.rb', line 17 def name @string.split(":").first end |
#primitive? ⇒ Boolean
51 52 53 |
# File 'lib/domain_builder/attribute.rb', line 51 def primitive? ['String', 'Integer', 'Currency'].include?(type) end |
#reference? ⇒ Boolean
37 38 39 |
# File 'lib/domain_builder/attribute.rb', line 37 def reference? !primitive? && !list? end |
#referenced_object ⇒ Object
45 46 47 48 49 |
# File 'lib/domain_builder/attribute.rb', line 45 def referenced_object return unless reference? return @string.split("::").last if @string.include?("::") @string.split(":").last end |