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.
110 111 112 113 114 115 |
# File 'app/controllers/concerns/olivander/resources/auto_form_attributes.rb', line 110 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.
108 109 110 |
# File 'app/controllers/concerns/olivander/resources/auto_form_attributes.rb', line 108 def editable @editable end |
#fields ⇒ Object
Returns the value of attribute fields.
108 109 110 |
# File 'app/controllers/concerns/olivander/resources/auto_form_attributes.rb', line 108 def fields @fields end |
#forced_section ⇒ Object
Returns the value of attribute forced_section.
108 109 110 |
# File 'app/controllers/concerns/olivander/resources/auto_form_attributes.rb', line 108 def forced_section @forced_section end |
#key ⇒ Object
Returns the value of attribute key.
108 109 110 |
# File 'app/controllers/concerns/olivander/resources/auto_form_attributes.rb', line 108 def key @key end |
#sections ⇒ Object
Returns the value of attribute sections.
108 109 110 |
# File 'app/controllers/concerns/olivander/resources/auto_form_attributes.rb', line 108 def sections @sections end |
Instance Method Details
#add_field(sym, type, editable) ⇒ Object
117 118 119 120 121 122 123 |
# File 'app/controllers/concerns/olivander/resources/auto_form_attributes.rb', line 117 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
131 132 133 |
# File 'app/controllers/concerns/olivander/resources/auto_form_attributes.rb', line 131 def max_section_columns sections.collect{ |x| x.columns }.max end |
#next_section(columns = 1) ⇒ Object
125 126 127 128 129 |
# File 'app/controllers/concerns/olivander/resources/auto_form_attributes.rb', line 125 def next_section(columns = 1) section = ResourceFieldSection.new(columns) sections << section section end |