Permalink
Browse files

#store_list_for and #list_for fixed: previously compacted only with v…

…alues, now do it for values AND a block.
  • Loading branch information...
1 parent 068bebf commit b137ab14f7ddf3811db87297369f882d13698a1b @chrisberkhout chrisberkhout committed with benhoskings Jan 16, 2011
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/babushka/accepts_list_for.rb
@@ -19,7 +19,7 @@ def #{method_name} *args, &block
elsif args.blank? && block.nil?
#{opts[:type]}_for #{method_name.inspect}, #{default.inspect}
else
- store_#{opts[:type]}_for #{method_name.inspect}, block || [*args.compact].flatten, #{opts[:choose_with].inspect}
+ store_#{opts[:type]}_for #{method_name.inspect}, block || [*args].flatten, #{opts[:choose_with].inspect}
self
end
end
@@ -37,7 +37,7 @@ def store_list_for method_name, data, choose_with
def list_for method_name, default
if payload.has_key? method_name
- payload[method_name].map {|i| i.respond_to?(:call) ? i.call : i }
+ payload[method_name].map {|i| i.respond_to?(:call) ? i.call : i }.compact
else
[*(default.is_a?(Symbol) ? send(default) : (default || []))]
end

0 comments on commit b137ab1

Please sign in to comment.