From dda200645a85c10d7475e4dc80e4797b2c2ef12c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Mon, 10 Mar 2014 18:40:54 -0300 Subject: [PATCH] Store the wrapper API attributes in the leaves --- lib/simple_form/wrappers/builder.rb | 4 ++-- lib/simple_form/wrappers/leaf.rb | 5 +++-- lib/simple_form/wrappers/single.rb | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/simple_form/wrappers/builder.rb b/lib/simple_form/wrappers/builder.rb index 685efde4..ca18ce8f 100644 --- a/lib/simple_form/wrappers/builder.rb +++ b/lib/simple_form/wrappers/builder.rb @@ -47,9 +47,9 @@ module SimpleForm def use(name, options=nil, &block) if options && wrapper = options[:wrap_with] - @components << Single.new(name, wrapper) + @components << Single.new(name, wrapper, options.except(:wrap_with)) else - @components << Leaf.new(name) + @components << Leaf.new(name, options) end end diff --git a/lib/simple_form/wrappers/leaf.rb b/lib/simple_form/wrappers/leaf.rb index 06efbbbf..037b8d8d 100644 --- a/lib/simple_form/wrappers/leaf.rb +++ b/lib/simple_form/wrappers/leaf.rb @@ -1,10 +1,11 @@ module SimpleForm module Wrappers class Leaf - attr_reader :namespace + attr_reader :namespace, :options - def initialize(namespace) + def initialize(namespace, options={}) @namespace = namespace + @options = options end def render(input) diff --git a/lib/simple_form/wrappers/single.rb b/lib/simple_form/wrappers/single.rb index 2f62b31e..70ffe0a5 100644 --- a/lib/simple_form/wrappers/single.rb +++ b/lib/simple_form/wrappers/single.rb @@ -2,8 +2,8 @@ module SimpleForm module Wrappers # `Single` is an optimization for a wrapper that has only one component. class Single < Many - def initialize(name, options={}) - super(name, [Leaf.new(name)], options) + def initialize(name, wrapper_options={}, options={}) + super(name, [Leaf.new(name, options)], wrapper_options) end def render(input)