Class: SimpleForm::Wrappers::Root

Inherits:
Many
  • Object
show all
Defined in:
lib/simple_form/wrappers/root.rb

Overview

‘Root` is the root wrapper for all components. It is special cased to always have a namespace and to add special html classes.

Instance Attribute Summary collapse

Attributes inherited from Many

#components, #defaults, #namespace

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Root

Returns a new instance of Root.



8
9
10
11
# File 'lib/simple_form/wrappers/root.rb', line 8

def initialize(*args)
  super(:wrapper, *args)
  @options = @defaults.except(:tag, :class, :error_class, :hint_class)
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'lib/simple_form/wrappers/root.rb', line 6

def options
  @options
end

Instance Method Details

#find(name) ⇒ Object

Provide a fallback if name cannot be found.



19
20
21
# File 'lib/simple_form/wrappers/root.rb', line 19

def find(name)
  super || SimpleForm::Wrappers::Many.new(name, [name])
end

#render(input) ⇒ Object



13
14
15
16
# File 'lib/simple_form/wrappers/root.rb', line 13

def render(input)
  input.options.reverse_merge!(@options)
  super
end