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

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

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

Methods included from Serializable

#derive, 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)


15
16
17
18
# File 'lib/yoda/store/objects/value_object.rb', line 15

def initialize(value: nil, **kwargs)
  super(kwargs)
  @value = value
end

Instance Attribute Details

#valueString (readonly)

Returns:

  • (String)


6
7
8
# File 'lib/yoda/store/objects/value_object.rb', line 6

def value
  @value
end

Class Method Details

.attr_namesArray<Symbol>

Returns:

  • (Array<Symbol>)


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

def self.attr_names
  super + %i(value)
end

Instance Method Details

#kindObject



25
26
27
# File 'lib/yoda/store/objects/value_object.rb', line 25

def kind
  :value
end

#nameString

Returns:

  • (String)


21
22
23
# File 'lib/yoda/store/objects/value_object.rb', line 21

def name
  @name ||= path.match(MODULE_TAIL_PATTERN) { |md| md[1] || md[2] }
end

#to_hObject



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

def to_h
  super.merge(value: value)
end