-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Be able to patch for nested associations require
includes
though ch…
…ild associations are already included
- Loading branch information
Showing
7 changed files
with
59 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# frozen_string_literal: true | ||
|
||
module BulletmarkRepairer | ||
class LoadedAssociations | ||
attr_reader :associations | ||
|
||
def key(target_klass_name) | ||
key = target_klass_name.underscore | ||
|
||
result = nil | ||
@associations.each do |_base_klass_name, all_associations| | ||
all_associations.each do |_key, associations| | ||
# TODO: return key | ||
# TODO: reccurent check | ||
associations.any? do |values| | ||
result = key.pluralize.to_sym if key.pluralize.to_sym.in?(values) | ||
result = key.singularize.to_sym if key.singularize.to_sym.in?(values) | ||
end | ||
end | ||
end | ||
result | ||
end | ||
|
||
def initialize(original_associations) | ||
@associations = Hash.new { |h, k| h[k] = {} } | ||
original_associations.each do |base_class, all_associations| | ||
all_associations.each do |key, associations| | ||
@associations[base_class][key] = associations.to_a | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters