Class: DynamicScaffold::Form::Item::JSONObject

Inherits:
Base
  • Object
show all
Defined in:
lib/dynamic_scaffold/form/item/json_object.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#multiple, #name, #parent_item

Instance Method Summary collapse

Methods inherited from Base

create, #default, #default_value, #errors, #if, #insert, #label, #label?, #needs_rendering?, #note, #notes?, #proxy, #proxy_field, #render_notes, #type?, #unique_name, #unless

Constructor Details

#initialize(config, type, name, options = {}) {|@form| ... } ⇒ JSONObject

Returns a new instance of JSONObject.

Yields:



8
9
10
11
12
13
14
# File 'lib/dynamic_scaffold/form/item/json_object.rb', line 8

def initialize(config, type, name, options = {})
  super
  @options = options
  @form = FormBuilder.new(config)
  @form.parent_item = self
  yield(@form)
end

Instance Attribute Details

#formObject (readonly)

Returns the value of attribute form.



7
8
9
# File 'lib/dynamic_scaffold/form/item/json_object.rb', line 7

def form
  @form
end

Instance Method Details

#extract_parameters(permitting) ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'lib/dynamic_scaffold/form/item/json_object.rb', line 21

def extract_parameters(permitting)
  hash = permitting.find {|e| e.is_a?(Hash) && e.key?(name) }
  if hash.nil?
    hash = {}
    hash[name] = form.items.map(&:name)
    permitting << hash
  else
    hash[name].concat(form.items.map(&:name))
  end
end

#render_label(_view, _depth) ⇒ Object

the lable is always empty.



17
18
19
# File 'lib/dynamic_scaffold/form/item/json_object.rb', line 17

def render_label(_view, _depth)
  ''
end