Class: Terrazzo::Page::Form

Inherits:
Base
  • Object
show all
Defined in:
lib/terrazzo/page/form.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#dashboard, #resource_class

Instance Method Summary collapse

Constructor Details

#initialize(dashboard, resource) ⇒ Form

Returns a new instance of Form.



6
7
8
9
# File 'lib/terrazzo/page/form.rb', line 6

def initialize(dashboard, resource)
  super(dashboard, resource.class)
  @resource = resource
end

Instance Attribute Details

#resourceObject (readonly)

Returns the value of attribute resource.



4
5
6
# File 'lib/terrazzo/page/form.rb', line 4

def resource
  @resource
end

Instance Method Details

#attributes(action = nil) ⇒ Object



16
17
18
19
20
21
# File 'lib/terrazzo/page/form.rb', line 16

def attributes(action = nil)
  attrs = dashboard.form_attributes(action)
  dashboard.flatten_attributes(attrs).map do |attr|
    dashboard.attribute_type_for(attr).new(attr, nil, :form, resource: resource)
  end
end

#grouped_attributes(action = nil) ⇒ Object



11
12
13
14
# File 'lib/terrazzo/page/form.rb', line 11

def grouped_attributes(action = nil)
  attrs = dashboard.form_attributes(action)
  normalize_groups(attrs, :form)
end