Skip to content

Commit

Permalink
Rename find_records to allow detection of overrides that will break…
Browse files Browse the repository at this point in the history
… during upgrade
  • Loading branch information
lgebhardt committed Feb 25, 2019
1 parent 6ef031b commit 924f5c5
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions lib/jsonapi/active_relation_resource_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ def find(filters, options = {})

paginator = options[:paginator]

records = find_records(records: records(options),
sort_criteria: sort_criteria,
filters: filters,
records = apply_request_settings_to_records(records: records(options),
sort_criteria: sort_criteria,filters: filters,
join_manager: join_manager,
paginator: paginator,
options: options)
Expand All @@ -45,7 +44,7 @@ def count(filters, options = {})
join_manager = JoinManager.new(resource_klass: self,
filters: filters)

records = find_records(records: records(options),
records = apply_request_settings_to_records(records: records(options),
filters: filters,
join_manager: join_manager,
options: options)
Expand Down Expand Up @@ -100,7 +99,7 @@ def find_fragments(filters, options = {})

paginator = options[:paginator]

records = find_records(records: records(options),
records = apply_request_settings_to_records(records: records(options),
filters: filters,
sort_criteria: sort_criteria,
paginator: paginator,
Expand Down Expand Up @@ -229,7 +228,7 @@ def count_related(source_rid, relationship_name, options = {})
source_relationship: relationship,
filters: filters)

records = find_records(records: records(options),
records = apply_request_settings_to_records(records: records(options),
resource_klass: related_klass,
primary_keys: source_rid.id,
join_manager: join_manager,
Expand Down Expand Up @@ -306,13 +305,13 @@ def to_one_relationships_for_linkage(include_related)
end

def find_record_by_key(key, options = {})
record = find_records(records: records(options), primary_keys: key, options: options).first
record = apply_request_settings_to_records(records: records(options), primary_keys: key, options: options).first
fail JSONAPI::Exceptions::RecordNotFound.new(key) if record.nil?
record
end

def find_records_by_keys(keys, options = {})
find_records(records: records(options), primary_keys: keys, options: options)
apply_request_settings_to_records(records: records(options), primary_keys: keys, options: options)
end

def find_related_monomorphic_fragments(source_rids, relationship, options, connect_source_identity)
Expand All @@ -337,7 +336,7 @@ def find_related_monomorphic_fragments(source_rids, relationship, options, conne

paginator = options[:paginator] if source_rids.count == 1

records = find_records(records: records(options),
records = apply_request_settings_to_records(records: records(options),
resource_klass: resource_klass,
sort_criteria: sort_criteria,
primary_keys: source_ids,
Expand Down Expand Up @@ -464,7 +463,7 @@ def find_related_polymorphic_fragments(source_rids, relationship, options, conne

# Note: We will sort by the source table. Without using unions we can't sort on a polymorphic relationship
# in any manner that makes sense
records = find_records(records: records(options),
records = apply_request_settings_to_records(records: records(options),
resource_klass: resource_klass,
sort_primary: true,
primary_keys: source_ids,
Expand Down Expand Up @@ -615,7 +614,7 @@ def find_related_polymorphic_fragments(source_rids, relationship, options, conne
related_fragments
end

def find_records(records:,
def apply_request_settings_to_records(records:,
join_manager: JoinManager.new(resource_klass: self),
resource_klass: self,
filters: {},
Expand Down

0 comments on commit 924f5c5

Please sign in to comment.