Initialize fieldset.

This commit is contained in:
Lucas Hosseini
2015-10-25 19:56:43 +01:00
parent 13ef8fed1b
commit b5aecfd114
2 changed files with 4 additions and 10 deletions

View File

@@ -2,7 +2,7 @@ module ActiveModel
class Serializer
class Fieldset
def initialize(fields)
@raw_fields = fields
@raw_fields = fields || {}
end
def fields
@@ -21,7 +21,7 @@ module ActiveModel
def parsed_fields
if raw_fields.is_a?(Hash)
raw_fields.inject({}) { |h, (k, v)| h[k.to_sym] = v.map(&:to_sym); h }
raw_fields.each_with_object({}) { |(k, v), h| h[k.to_sym] = v.map(&:to_sym) }
else
{}
end