lib/ivy/serializers/formats/json.rb in ivy-serializers-0.3.0 vs lib/ivy/serializers/formats/json.rb in ivy-serializers-0.4.0

- old
+ new

@@ -1,7 +1,7 @@ -require 'active_support/inflector' require 'hash_generator' +require 'inflecto' module Ivy module Serializers module Formats class JSON @@ -46,13 +46,15 @@ def included(document) document.generate_included_resources(self) end - def included_resources(resource_class, resources) - key = key_for_collection(resource_class).to_sym - @hash_gen.store_array(key) { resources(resources) } + def included_resources(included_resources) + included_resources.each_pair do |resource_class, resources| + key = key_for_collection(resource_class).to_sym + @hash_gen.store_array(key) { resources(resources) } + end end def primary_resource(primary_resource_name, primary_resource) @hash_gen.store_object(primary_resource_name) { resource(primary_resource) } end @@ -83,18 +85,18 @@ def extract_id(resource) resource.id if resource end def extract_type(resource) - ActiveSupport::Inflector.dasherize(key_for_individual(resource.class)) + Inflecto.dasherize(key_for_individual(resource.class)) end def key_for_collection(resource_class) - ActiveSupport::Inflector.pluralize(key_for_individual(resource_class)) + Inflecto.pluralize(key_for_individual(resource_class)) end def key_for_individual(resource_class) - ActiveSupport::Inflector.underscore(resource_class.name) + Inflecto.underscore(resource_class.name) end end end end end