1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

wrap up hash conversion in the constructor

This commit is contained in:
Aaron Patterson 2012-11-13 13:39:42 -08:00
parent fc29bff445
commit df3b650810

View file

@ -75,7 +75,11 @@ module ActionController
Options = Struct.new(:name, :format, :include, :exclude) do # :nodoc:
def self.from_hash(hash)
new(*hash.values_at(:name, :format, :include, :exclude))
name = hash[:name]
format = Array(hash[:format])
include = hash[:include] && Array(hash[:include]).collect(&:to_s)
exclude = hash[:exclude] && Array(hash[:exclude]).collect(&:to_s)
new name, format, include, exclude
end
end
@ -187,10 +191,6 @@ module ActionController
controller_name.singularize
end
opts.format = Array(opts.format)
opts.include &&= Array(opts.include).collect(&:to_s)
opts.exclude &&= Array(opts.exclude).collect(&:to_s)
self._wrapper_options = opts
end
end