Class: Yoda::Store::Objects::ValueObject
- Defined in:
- lib/yoda/store/objects/value_object.rb
Defined Under Namespace
Classes: Connected
Instance Attribute Summary collapse
- #value ⇒ String readonly
Attributes inherited from Base
#document, #path, #primary_source, #sources, #tag_list
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(value: nil, **kwargs) ⇒ ValueObject
constructor
A new instance of ValueObject.
- #kind ⇒ Object
- #name ⇒ String
- #to_h ⇒ Object
Methods inherited from Base
#==, #address, #eql?, #hash, #merge, #meta_class_address, #namespace?, #parent_address, #with_connection
Methods included from Serializable
#==, #derive, #eql?, #hash, included, #to_json
Methods included from Addressable
Constructor Details
#initialize(value: nil, **kwargs) ⇒ ValueObject
Returns a new instance of ValueObject.
19 20 21 22 |
# File 'lib/yoda/store/objects/value_object.rb', line 19 def initialize(value: nil, **kwargs) super(**kwargs) @value = value end |
Instance Attribute Details
#value ⇒ String (readonly)
10 11 12 |
# File 'lib/yoda/store/objects/value_object.rb', line 10 def value @value end |
Class Method Details
.attr_names ⇒ Array<Symbol>
13 14 15 |
# File 'lib/yoda/store/objects/value_object.rb', line 13 def self.attr_names super + %i(value) end |
Instance Method Details
#kind ⇒ Object
29 30 31 |
# File 'lib/yoda/store/objects/value_object.rb', line 29 def kind :value end |
#name ⇒ String
25 26 27 |
# File 'lib/yoda/store/objects/value_object.rb', line 25 def name @name ||= path.match(MODULE_TAIL_PATTERN) { |md| md[1] || md[2] } end |
#to_h ⇒ Object
33 34 35 |
# File 'lib/yoda/store/objects/value_object.rb', line 33 def to_h super.merge(value: value) end |