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:
parent
fc29bff445
commit
df3b650810
1 changed files with 5 additions and 5 deletions
|
@ -75,7 +75,11 @@ module ActionController
|
||||||
|
|
||||||
Options = Struct.new(:name, :format, :include, :exclude) do # :nodoc:
|
Options = Struct.new(:name, :format, :include, :exclude) do # :nodoc:
|
||||||
def self.from_hash(hash)
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -187,10 +191,6 @@ module ActionController
|
||||||
controller_name.singularize
|
controller_name.singularize
|
||||||
end
|
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
|
self._wrapper_options = opts
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue