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