Class: Olivander::Resources::ResourceFields::ResourceFieldGroup
- Inherits:
-
Object
- Object
- Olivander::Resources::ResourceFields::ResourceFieldGroup
- Defined in:
- app/controllers/concerns/olivander/resources/auto_form_attributes.rb
Instance Attribute Summary collapse
-
#editable ⇒ Object
Returns the value of attribute editable.
-
#fields ⇒ Object
Returns the value of attribute fields.
-
#forced_section ⇒ Object
Returns the value of attribute forced_section.
-
#key ⇒ Object
Returns the value of attribute key.
-
#sections ⇒ Object
Returns the value of attribute sections.
Instance Method Summary collapse
- #add_field(sym, type, editable) ⇒ Object
-
#initialize(key, editable) ⇒ ResourceFieldGroup
constructor
A new instance of ResourceFieldGroup.
- #max_section_columns ⇒ Object
- #next_section(columns = 1) ⇒ Object
Constructor Details
#initialize(key, editable) ⇒ ResourceFieldGroup
Returns a new instance of ResourceFieldGroup.
118 119 120 121 122 123 |
# File 'app/controllers/concerns/olivander/resources/auto_form_attributes.rb', line 118 def initialize(key, editable) self.key = key self.editable = editable self.fields = [] self.sections = [] end |
Instance Attribute Details
#editable ⇒ Object
Returns the value of attribute editable.
116 117 118 |
# File 'app/controllers/concerns/olivander/resources/auto_form_attributes.rb', line 116 def editable @editable end |
#fields ⇒ Object
Returns the value of attribute fields.
116 117 118 |
# File 'app/controllers/concerns/olivander/resources/auto_form_attributes.rb', line 116 def fields @fields end |
#forced_section ⇒ Object
Returns the value of attribute forced_section.
116 117 118 |
# File 'app/controllers/concerns/olivander/resources/auto_form_attributes.rb', line 116 def forced_section @forced_section end |
#key ⇒ Object
Returns the value of attribute key.
116 117 118 |
# File 'app/controllers/concerns/olivander/resources/auto_form_attributes.rb', line 116 def key @key end |
#sections ⇒ Object
Returns the value of attribute sections.
116 117 118 |
# File 'app/controllers/concerns/olivander/resources/auto_form_attributes.rb', line 116 def sections @sections end |
Instance Method Details
#add_field(sym, type, editable) ⇒ Object
125 126 127 128 129 130 131 |
# File 'app/controllers/concerns/olivander/resources/auto_form_attributes.rb', line 125 def add_field(sym, type, editable) e = editable.nil? ? self.editable : editable section = forced_section || next_section field = ResourceField.new(sym, type, e, self) section.fields << field fields << field end |
#max_section_columns ⇒ Object
139 140 141 |
# File 'app/controllers/concerns/olivander/resources/auto_form_attributes.rb', line 139 def max_section_columns sections.collect{ |x| x.columns }.max end |
#next_section(columns = 1) ⇒ Object
133 134 135 136 137 |
# File 'app/controllers/concerns/olivander/resources/auto_form_attributes.rb', line 133 def next_section(columns = 1) section = ResourceFieldSection.new(columns) sections << section section end |