Class: Olivander::Resources::ResourceFields::ResourceFieldGroup

Inherits:
Object
  • Object
show all
Defined in:
app/controllers/concerns/olivander/resources/auto_form_attributes.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#editableObject

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

#fieldsObject

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_sectionObject

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

#keyObject

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

#sectionsObject

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_columnsObject



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