lib/active_model/serializer/fieldset.rb in cheap_ams-0.10.5 vs lib/active_model/serializer/fieldset.rb in cheap_ams-0.10.6
- old
+ new
@@ -1,9 +1,8 @@
module ActiveModel
class Serializer
class Fieldset
-
def initialize(fields, root = nil)
@root = root
@raw_fields = fields
end
@@ -14,19 +13,19 @@
def fields_for(serializer)
key = serializer.json_key
fields[key.to_sym] || fields[key.pluralize.to_sym]
end
- private
+ private
ActiveModelSerializers.silence_warnings do
attr_reader :raw_fields, :root
end
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.inject({}) { |h, (k, v)| h[k.to_sym] = v.map(&:to_sym); h }
elsif raw_fields.is_a?(Array)
if root.nil?
raise ArgumentError, 'The root argument must be specified if the fileds argument is an array.'
end
hash = {}
@@ -34,9 +33,8 @@
hash
else
{}
end
end
-
end
end
end