# File lib/ivy/serializers/formats/json_api.rb, line 31 def primary_resource(primary_resource_name, primary_resource) super(:data, primary_resource) end
class Ivy::Serializers::Formats::JSONAPI
Public Instance Methods
attributes(resource)
click to toggle source
Calls superclass method
Ivy::Serializers::Formats::JSON#attributes
# File lib/ivy/serializers/formats/json_api.rb, line 7 def attributes(resource) @hash_gen.store_object(:attributes) { super } end
belongs_to(name, resource, options={})
click to toggle source
# File lib/ivy/serializers/formats/json_api.rb, line 11 def belongs_to(name, resource, options={}) if resource @hash_gen.store_object(name) { linkage(resource) } else @hash_gen.store(name, nil) end end
has_many(name, resources, options={})
click to toggle source
# File lib/ivy/serializers/formats/json_api.rb, line 19 def has_many(name, resources, options={}) @hash_gen.store_object(name) { linkages(resources) } end
included(document)
click to toggle source
Calls superclass method
Ivy::Serializers::Formats::JSON#included
# File lib/ivy/serializers/formats/json_api.rb, line 23 def included(document) @hash_gen.store_array(:included) { super } end
included_resources(included_resources)
click to toggle source
# File lib/ivy/serializers/formats/json_api.rb, line 27 def included_resources(included_resources) included_resources.each_value { |resources| resources(resources) } end
primary_resource(primary_resource_name, primary_resource)
click to toggle source
Calls superclass method
Ivy::Serializers::Formats::JSON#primary_resource
primary_resources(primary_resources_name, primary_resources)
click to toggle source
Calls superclass method
Ivy::Serializers::Formats::JSON#primary_resources
# File lib/ivy/serializers/formats/json_api.rb, line 35 def primary_resources(primary_resources_name, primary_resources) super(:data, primary_resources) end
relationships(document)
click to toggle source
Calls superclass method
Ivy::Serializers::Formats::JSON#relationships
# File lib/ivy/serializers/formats/json_api.rb, line 39 def relationships(document) @hash_gen.store_object(:relationships) { super } end
resource(resource)
click to toggle source
Calls superclass method
Ivy::Serializers::Formats::JSON#resource
# File lib/ivy/serializers/formats/json_api.rb, line 43 def resource(resource) super type(:type, resource) end
Private Instance Methods
coerce_id(id)
click to toggle source
# File lib/ivy/serializers/formats/json_api.rb, line 50 def coerce_id(id) id.to_s end
extract_id(resource)
click to toggle source
Calls superclass method
Ivy::Serializers::Formats::JSON#extract_id
# File lib/ivy/serializers/formats/json_api.rb, line 54 def extract_id(resource) coerce_id(super) end
linkage(resource)
click to toggle source
# File lib/ivy/serializers/formats/json_api.rb, line 58 def linkage(resource) @hash_gen.store_object(:data) { linkage_object(resource) } end
linkage_object(resource)
click to toggle source
# File lib/ivy/serializers/formats/json_api.rb, line 62 def linkage_object(resource) id(:id, resource) type(:type, resource) end
linkage_objects(resources)
click to toggle source
# File lib/ivy/serializers/formats/json_api.rb, line 71 def linkage_objects(resources) resources.each { |resource| @hash_gen.push_object { linkage_object(resource) } } end
linkages(resources)
click to toggle source
# File lib/ivy/serializers/formats/json_api.rb, line 67 def linkages(resources) @hash_gen.store_array(:data) { linkage_objects(resources) } end