lib/jsonapi/resource_serializer.rb in jsonapi-resources-0.6.2 vs lib/jsonapi/resource_serializer.rb in jsonapi-resources-0.7.0
- old
+ new
@@ -1,9 +1,9 @@
module JSONAPI
class ResourceSerializer
- attr_reader :url_generator, :key_formatter, :serialization_options, :primary_class_name
+ attr_reader :link_builder, :key_formatter, :serialization_options, :primary_class_name
# initialize
# Options can include
# include:
# Purpose: determines which objects will be side loaded with the source objects in a linked section
@@ -19,11 +19,11 @@
@primary_class_name = primary_resource_klass._type
@fields = options.fetch(:fields, {})
@include = options.fetch(:include, [])
@include_directives = options[:include_directives]
@key_formatter = options.fetch(:key_formatter, JSONAPI.configuration.key_formatter)
- @url_generator = generate_link_builder(primary_resource_klass, options)
+ @link_builder = generate_link_builder(primary_resource_klass, options)
@always_include_to_one_linkage_data = options.fetch(:always_include_to_one_linkage_data,
JSONAPI.configuration.always_include_to_one_linkage_data)
@always_include_to_many_linkage_data = options.fetch(:always_include_to_many_linkage_data,
JSONAPI.configuration.always_include_to_many_linkage_data)
@serialization_options = options.fetch(:serialization_options, {})
@@ -70,12 +70,12 @@
},
data: data
}
end
- def find_link(query_params)
- url_generator.query_link(query_params)
+ def query_link(query_params)
+ link_builder.query_link(query_params)
end
def format_key(key)
@key_formatter.format(key)
end
@@ -224,25 +224,25 @@
end
end
def relationship_links(source)
links = {}
- links[:self] = url_generator.self_link(source)
+ links[:self] = link_builder.self_link(source)
links
end
def already_serialized?(type, id)
type = format_key(type)
@included_objects.key?(type) && @included_objects[type].key?(id)
end
def self_link(source, relationship)
- url_generator.relationships_self_link(source, relationship)
+ link_builder.relationships_self_link(source, relationship)
end
def related_link(source, relationship)
- url_generator.relationships_related_link(source, relationship)
+ link_builder.relationships_related_link(source, relationship)
end
def to_one_linkage(source, relationship)
linkage = {}
linkage_id = foreign_key_value(source, relationship)