Permalink
Browse files

tweak sanitize_for to set result once

  • Loading branch information...
1 parent 1e73bd1 commit 474155dcee7ca11525ebcc430efe238b4fcb8a36 @zenhob committed Mar 7, 2012
Showing with 1 addition and 2 deletions.
  1. +1 −2 lib/accessible_for.rb
View
@@ -26,13 +26,12 @@ def sanitize_for role, values
if !self.class._accessible_attributes || self.class._accessible_attributes[role].nil?
return {}
end
- result = nil
+ result = block_given? ? nil : {}
values.each do |k, v|
if self.class._accessible_attributes[role].include?(k.to_sym)
if block_given?
yield k, v
else
- result ||= {}
result[k] = v
end
end

0 comments on commit 474155d

Please sign in to comment.