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.



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

#editableObject

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

#fieldsObject

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_sectionObject

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

#keyObject

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

#sectionsObject

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_columnsObject



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