Class: FlexiModel::ArModels::Value
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- FlexiModel::ArModels::Value
- Defined in:
- lib/flexi_model/ar_models/value.rb
Instance Method Summary collapse
- #column_for_attribute(name) ⇒ Object
-
#value ⇒ Object
Get value from corresponding column based on field type.
-
#value=(val) ⇒ Object
Set value based on field type.
Instance Method Details
#column_for_attribute(name) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/flexi_model/ar_models/value.rb', line 32 def column_for_attribute(name) if :value == name.to_sym self.class.columns_hash[self.field.value_column.to_s] else self.class.columns_hash[name.to_s] end end |
#value ⇒ Object
Get value from corresponding column based on field type
28 29 30 |
# File 'lib/flexi_model/ar_models/value.rb', line 28 def value self.send :"#{_mapped_value_column}" end |
#value=(val) ⇒ Object
Set value based on field type. ie. if it is ‘string` type it will store value in str_value
List of field value mappings -
Boolean 'bool_value'
Integer 'int_value'
Decimal 'dec_value'
String 'str_value'
Text 'txt_value'
Datetime 'dt_value'
23 24 25 |
# File 'lib/flexi_model/ar_models/value.rb', line 23 def value=(val) self.send :"#{_mapped_value_column}=", val end |