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) ⇒ 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.
112 113 114 115 |
# File 'lib/para/components_configuration.rb', line 112 def initialize(identifier, &block) self.identifier = identifier.to_s instance_eval(&block) end |
Instance Attribute Details
#identifier ⇒ Object
Returns the value of attribute identifier.
110 111 112 |
# File 'lib/para/components_configuration.rb', line 110 def identifier @identifier end |
#model ⇒ Object
Returns the value of attribute model.
110 111 112 |
# File 'lib/para/components_configuration.rb', line 110 def model @model end |
Instance Method Details
#component(*args) ⇒ Object
117 118 119 |
# File 'lib/para/components_configuration.rb', line 117 def component(*args) components << Component.new(*args) end |
#components ⇒ Object
121 122 123 |
# File 'lib/para/components_configuration.rb', line 121 def components @components ||= [] end |
#refresh(attributes = {}) ⇒ Object
125 126 127 128 129 130 131 132 133 |
# File 'lib/para/components_configuration.rb', line 125 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 |