Module: Sunrise::Config::HasFields
Overview
Provides accessors and autoregistering of model’s fields.
Instance Method Summary collapse
-
#field(name = :custom, options = {}, &block) ⇒ Object
Defines a configuration for a field.
-
#fields ⇒ Object
Array for store all defined fields.
-
#nested_attributes(name, options = {}, &block) ⇒ Object
Defines a configuration for a nested attributes.
Instance Method Details
#field(name = :custom, options = {}, &block) ⇒ Object
Defines a configuration for a field.
16 17 18 19 |
# File 'lib/sunrise/config/has_fields.rb', line 16 def field(name = :custom, = {}, &block) = { name: name.to_sym }.merge() fields << Field.new(abstract_model, self, , &block) end |
#fields ⇒ Object
Array for store all defined fields
11 12 13 |
# File 'lib/sunrise/config/has_fields.rb', line 11 def fields @fields ||= [] end |
#nested_attributes(name, options = {}, &block) ⇒ Object
Defines a configuration for a nested attributes
22 23 24 25 26 27 |
# File 'lib/sunrise/config/has_fields.rb', line 22 def nested_attributes(name, = {}, &block) = { name: name.to_sym }.merge() nested_field = NestedField.new(abstract_model, self, ) nested_field.instance_eval &block if block fields << nested_field end |