Class: HecksDomainBuilder::DomainObject
- Inherits:
-
Object
- Object
- HecksDomainBuilder::DomainObject
- Defined in:
- lib/domain_builder/domain_object.rb
Overview
A Domain Object
Instance Attribute Summary collapse
-
#attributes(*values) ⇒ Object
readonly
Returns the value of attribute attributes.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #attribute_hash ⇒ Object
- #attribute_string ⇒ Object
- #domain_references ⇒ Object
-
#initialize(name:) ⇒ DomainObject
constructor
A new instance of DomainObject.
- #references ⇒ Object
Constructor Details
#initialize(name:) ⇒ DomainObject
Returns a new instance of DomainObject.
6 7 8 |
# File 'lib/domain_builder/domain_object.rb', line 6 def initialize(name:) @name = name end |
Instance Attribute Details
#attributes(*values) ⇒ Object (readonly)
Returns the value of attribute attributes.
4 5 6 |
# File 'lib/domain_builder/domain_object.rb', line 4 def attributes @attributes end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/domain_builder/domain_object.rb', line 4 def name @name end |
Instance Method Details
#attribute_hash ⇒ Object
15 16 17 18 19 |
# File 'lib/domain_builder/domain_object.rb', line 15 def attribute_hash attributes.map do |attribute| [attribute.name.to_sym, type_with_domain_module(attribute)] end.to_h end |
#attribute_string ⇒ Object
21 22 23 24 25 |
# File 'lib/domain_builder/domain_object.rb', line 21 def attribute_string attributes.map do |attribute| [attribute.name, type_with_domain_module(attribute)].join(':') end end |
#domain_references ⇒ Object
31 32 33 |
# File 'lib/domain_builder/domain_object.rb', line 31 def domain_references @attributes.select(&:domain_reference?) end |
#references ⇒ Object
27 28 29 |
# File 'lib/domain_builder/domain_object.rb', line 27 def references @attributes.reject(&:primitive?) end |