Class: Seedie::FieldValuesSet
- Inherits:
-
Object
- Object
- Seedie::FieldValuesSet
- Defined in:
- lib/seedie/field_values_set.rb
Instance Attribute Summary collapse
-
#attributes_config ⇒ Object
readonly
Returns the value of attribute attributes_config.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#model_config ⇒ Object
readonly
Returns the value of attribute model_config.
Instance Method Summary collapse
- #generate_field_value(name, column) ⇒ Object
- #generate_field_values ⇒ Object
- #generate_field_values_with_associations ⇒ Object
-
#initialize(model, model_config, index) ⇒ FieldValuesSet
constructor
A new instance of FieldValuesSet.
Constructor Details
#initialize(model, model_config, index) ⇒ FieldValuesSet
Returns a new instance of FieldValuesSet.
7 8 9 10 11 12 13 14 |
# File 'lib/seedie/field_values_set.rb', line 7 def initialize(model, model_config, index) @model = model @model_config = model_config @index = index @attributes_config = model_config["attributes"] @model_fields = ModelFields.new(model, model_config) @field_values = {} end |
Instance Attribute Details
#attributes_config ⇒ Object (readonly)
Returns the value of attribute attributes_config.
5 6 7 |
# File 'lib/seedie/field_values_set.rb', line 5 def attributes_config @attributes_config end |
#index ⇒ Object (readonly)
Returns the value of attribute index.
5 6 7 |
# File 'lib/seedie/field_values_set.rb', line 5 def index @index end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
5 6 7 |
# File 'lib/seedie/field_values_set.rb', line 5 def model @model end |
#model_config ⇒ Object (readonly)
Returns the value of attribute model_config.
5 6 7 |
# File 'lib/seedie/field_values_set.rb', line 5 def model_config @model_config end |
Instance Method Details
#generate_field_value(name, column) ⇒ Object
29 30 31 32 33 |
# File 'lib/seedie/field_values_set.rb', line 29 def generate_field_value(name, column) return generate_custom_field_value(name) if @attributes_config&.key?(name) FieldValues::FakeValue.new(name, column).generate_fake_value end |
#generate_field_values ⇒ Object
16 17 18 19 20 21 |
# File 'lib/seedie/field_values_set.rb', line 16 def generate_field_values populate_values_for_model_fields populate_values_for_virtual_fields if @attributes_config @field_values end |
#generate_field_values_with_associations ⇒ Object
23 24 25 26 27 |
# File 'lib/seedie/field_values_set.rb', line 23 def generate_field_values_with_associations associated_field_values_set = generate_belongs_to_associations model_field_values_set = generate_field_values model_field_values_set.merge!(associated_field_values_set) end |