Module: DecoLite::FieldAssignable
- Includes:
- FieldCreatable, FieldRetrievable
- Included in:
- HashLoadable, Model
- Defined in:
- lib/deco_lite/field_assignable.rb
Overview
Defines methods to assign model field values dynamically.
Constant Summary
Constants included from FieldValidatable
DecoLite::FieldValidatable::FIELD_NAME_REGEX
Constants included from FieldsOptionable
DecoLite::FieldsOptionable::OPTION_FIELDS, DecoLite::FieldsOptionable::OPTION_FIELDS_DEFAULT, DecoLite::FieldsOptionable::OPTION_FIELDS_MERGE, DecoLite::FieldsOptionable::OPTION_FIELDS_STRICT, DecoLite::FieldsOptionable::OPTION_FIELDS_VALUES
Instance Method Summary collapse
- #set_field_value(field_name:, value:, options:) ⇒ Object
- #set_field_values(hash:, field_info:, options:) ⇒ Object
Methods included from FieldRetrievable
Methods included from FieldCreatable
#create_field_accessor, #create_field_accessors
Methods included from FieldValidatable
Methods included from FieldConflictable
#attr_accessor_exist?, #field_conflict?, #field_names_include?, #validate_field_conflicts!
Methods included from FieldNameNamespaceable
#field_name_or_field_name_with_namespace, #field_name_with_namespace
Instance Method Details
#set_field_value(field_name:, value:, options:) ⇒ Object
19 20 21 22 23 |
# File 'lib/deco_lite/field_assignable.rb', line 19 def set_field_value(field_name:, value:, options:) # Create our fields before we send. create_field_accessor field_name: field_name, options: send("#{field_name}=", value) end |
#set_field_values(hash:, field_info:, options:) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/deco_lite/field_assignable.rb', line 12 def set_field_values(hash:, field_info:, options:) field_info.each do |name, info| value = get_field_value(hash: hash, field_info: info) set_field_value(field_name: name, value: value, options: ) end end |