Class: Sprig::Reap::Value

Inherits:
Object
  • Object
show all
Defined in:
lib/sprig/reap/value.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sprig_record, attribute) ⇒ Value

Returns a new instance of Value.



11
12
13
14
15
16
17
# File 'lib/sprig/reap/value.rb', line 11

def initialize(sprig_record, attribute)
  @sprig_record = sprig_record
  @record       = sprig_record.record
  @attribute    = attribute
  @value        = record.send(attribute)
  @raw_value    = record.read_attribute(attribute)
end

Instance Attribute Details

#attributeObject (readonly)

Returns the value of attribute attribute.



3
4
5
# File 'lib/sprig/reap/value.rb', line 3

def attribute
  @attribute
end

#raw_valueObject (readonly)

Returns the value of attribute raw_value.



3
4
5
# File 'lib/sprig/reap/value.rb', line 3

def raw_value
  @raw_value
end

#recordObject (readonly)

Returns the value of attribute record.



3
4
5
# File 'lib/sprig/reap/value.rb', line 3

def record
  @record
end

#sprig_recordObject (readonly)

Returns the value of attribute sprig_record.



3
4
5
# File 'lib/sprig/reap/value.rb', line 3

def sprig_record
  @sprig_record
end

#valueObject (readonly)

Returns the value of attribute value.



3
4
5
# File 'lib/sprig/reap/value.rb', line 3

def value
  @value
end

Class Method Details

.for(sprig_record, attribute) ⇒ Object



7
8
9
# File 'lib/sprig/reap/value.rb', line 7

def self.for(sprig_record, attribute)
  new(sprig_record, attribute).for_sprig_file
end

Instance Method Details

#for_sprig_fileObject



19
20
21
# File 'lib/sprig/reap/value.rb', line 19

def for_sprig_file
  @for_sprig_file ||= dependency? ? sprig_dependency_reference : read_attribute
end