Module: ActiveFields::ValueConcern

Extended by:
ActiveSupport::Concern
Included in:
Value
Defined in:
app/models/concerns/active_fields/value_concern.rb

Overview

Model mix-in with a base logic for the active fields value model

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#temp_valueObject (readonly)

Returns the value of attribute temp_value.



24
25
26
# File 'app/models/concerns/active_fields/value_concern.rb', line 24

def temp_value
  @temp_value
end

Instance Method Details

#valueObject



35
36
37
38
39
40
41
# File 'app/models/concerns/active_fields/value_concern.rb', line 35

def value
  return unless active_field

  assign_value_from_temp if temp_value

  active_field.value_caster.deserialize(value_meta["const"])
end

#value=(v) ⇒ Object



26
27
28
29
30
31
32
33
# File 'app/models/concerns/active_fields/value_concern.rb', line 26

def value=(v)
  if active_field
    clear_temp_value
    value_meta["const"] = active_field.value_caster.serialize(v)
  else
    assign_temp_value(v)
  end
end