Class: Para::ComponentsConfiguration::Section
- Inherits:
-
Object
- Object
- Para::ComponentsConfiguration::Section
- Defined in:
- lib/para/components_configuration.rb
Instance Attribute Summary collapse
-
#identifier ⇒ Object
Returns the value of attribute identifier.
-
#model ⇒ Object
Returns the value of attribute model.
Instance Method Summary collapse
- #component(*args, &block) ⇒ Object
- #components ⇒ Object
-
#initialize(identifier, &block) ⇒ Section
constructor
A new instance of Section.
- #refresh(attributes = {}) ⇒ Object
Constructor Details
#initialize(identifier, &block) ⇒ Section
Returns a new instance of Section.
148 149 150 151 |
# File 'lib/para/components_configuration.rb', line 148 def initialize(identifier, &block) self.identifier = identifier.to_s instance_eval(&block) end |
Instance Attribute Details
#identifier ⇒ Object
Returns the value of attribute identifier.
146 147 148 |
# File 'lib/para/components_configuration.rb', line 146 def identifier @identifier end |
#model ⇒ Object
Returns the value of attribute model.
146 147 148 |
# File 'lib/para/components_configuration.rb', line 146 def model @model end |
Instance Method Details
#component(*args, &block) ⇒ Object
153 154 155 |
# File 'lib/para/components_configuration.rb', line 153 def component(*args, &block) components << Component.new(*args, &block) end |
#components ⇒ Object
157 158 159 |
# File 'lib/para/components_configuration.rb', line 157 def components @components ||= [] end |
#refresh(attributes = {}) ⇒ Object
161 162 163 164 165 166 167 168 169 |
# File 'lib/para/components_configuration.rb', line 161 def refresh(attributes = {}) self.model = ComponentSection.where(identifier: identifier).first_or_initialize model.assign_attributes(attributes) model.save! components.each_with_index do |component, index| component.refresh(component_section: model, position: index) end end |