Do not use splat for clarity.
This commit is contained in:
parent
e34b6a6b4e
commit
1e91fb42c3
|
@ -106,7 +106,7 @@ module SimpleForm
|
|||
#
|
||||
def input_field(attribute_name, options={})
|
||||
options[:input_html] = options.except(:as, :collection, :label_method, :value_method)
|
||||
SimpleForm::Wrappers::Root.new(:input, :wrapper => false).render find_input(attribute_name, options)
|
||||
SimpleForm::Wrappers::Root.new([:input], :wrapper => false).render find_input(attribute_name, options)
|
||||
end
|
||||
|
||||
# Helper for dealing with association selects/radios, generating the
|
||||
|
|
|
@ -6,12 +6,12 @@ module SimpleForm
|
|||
|
||||
# TODO: Test the many case
|
||||
def self.find(name)
|
||||
SimpleForm.components.find { |c| c.to_sym == name } || SingleForm::Wrappers::Many.new(name, name)
|
||||
SimpleForm.components.find { |c| c.to_sym == name } || SingleForm::Wrappers::Many.new(name, [name])
|
||||
end
|
||||
|
||||
def self.wrap(array)
|
||||
Root.new(
|
||||
*(array.map do |item|
|
||||
array.map do |item|
|
||||
case item
|
||||
when :error
|
||||
Single.new(:error, :tag => SimpleForm.error_tag, :class => SimpleForm.error_class)
|
||||
|
@ -20,9 +20,10 @@ module SimpleForm
|
|||
else
|
||||
item
|
||||
end
|
||||
end << { :tag => SimpleForm.wrapper_tag,
|
||||
end,
|
||||
:tag => SimpleForm.wrapper_tag,
|
||||
:class => SimpleForm.wrapper_class,
|
||||
:error_class => SimpleForm.wrapper_error_class })
|
||||
:error_class => SimpleForm.wrapper_error_class
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,10 +6,10 @@ module SimpleForm
|
|||
attr_reader :namespace, :defaults, :components
|
||||
alias :to_sym :namespace
|
||||
|
||||
def initialize(namespace, *args)
|
||||
@defaults = args.extract_options!
|
||||
def initialize(namespace, components, defaults={})
|
||||
@namespace = namespace
|
||||
@components = args
|
||||
@components = components
|
||||
@defaults = defaults
|
||||
@defaults[:class] = Array.wrap(@defaults[:class])
|
||||
end
|
||||
|
||||
|
@ -33,7 +33,7 @@ module SimpleForm
|
|||
private
|
||||
|
||||
def wrap(input, options, content)
|
||||
tag = options[:"#{namespace}_tag"] || @defaults[:tag]
|
||||
tag = (namespace && options[:"#{namespace}_tag"]) || @defaults[:tag]
|
||||
return content unless tag
|
||||
|
||||
klass = html_classes(input, options)
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
module SimpleForm
|
||||
module Wrappers
|
||||
class Single < Many
|
||||
def initialize(name, options)
|
||||
super(name, name, options)
|
||||
def initialize(name, options={})
|
||||
super(name, [name], options)
|
||||
end
|
||||
|
||||
def render(input)
|
||||
|
|
Loading…
Reference in New Issue