Class: Yoda::Store::Objects::ValueObject

Inherits:
Base
  • Object
show all
Defined in:
lib/yoda/store/objects/value_object.rb

Defined Under Namespace

Classes: Connected

Instance Attribute Summary collapse

Attributes inherited from Base

#document, #path, #primary_source, #sources, #tag_list

Class Method Summary collapse

Instance Method Summary collapse

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

#address

Constructor Details

#initialize(value: nil, **kwargs) ⇒ ValueObject

Returns a new instance of ValueObject.

Parameters:

  • path (String)
  • value (String) (defaults to: nil)


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

#valueString (readonly)

Returns:

  • (String)


10
11
12
# File 'lib/yoda/store/objects/value_object.rb', line 10

def value
  @value
end

Class Method Details

.attr_namesArray<Symbol>

Returns:

  • (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

#kindObject



29
30
31
# File 'lib/yoda/store/objects/value_object.rb', line 29

def kind
  :value
end

#nameString

Returns:

  • (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_hObject



33
34
35
# File 'lib/yoda/store/objects/value_object.rb', line 33

def to_h
  super.merge(value: value)
end