Skip to content

Commit

Permalink
Merge pull request #310 from ifad/bugfix/309-method-visibility
Browse files Browse the repository at this point in the history
Fix patched association methods visibility
  • Loading branch information
tagliala authored Jun 2, 2024
2 parents f936ab6 + 3a5d7b2 commit cf544ce
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
8 changes: 4 additions & 4 deletions lib/chrono_model/patches/association.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ module Patches
# on the join model's (:through association) one.
#
module Association
def skip_statement_cache?(*)
super || _chrono_target?
end

# If the association class or the through association are ChronoModels,
# then fetches the records from a virtual table using a subquery scope
# to a specific timestamp.
Expand All @@ -36,6 +32,10 @@ def scope

private

def skip_statement_cache?(*)
super || _chrono_target?
end

def _chrono_record?
owner.class.include?(ChronoModel::Patches::AsOfTimeHolder) && owner.as_of_time.present?
end
Expand Down
4 changes: 4 additions & 0 deletions lib/chrono_model/patches/preloader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ def chronomodel_scope(given_preload_scope)
end

module Association
private

# Builds the preloader scope taking into account a potential
# +as_of_time+ passed down the call chain starting at the
# end user invocation.
Expand All @@ -49,6 +51,8 @@ def build_scope
end

module ThroughAssociation
private

# Builds the preloader scope taking into account a potential
# +as_of_time+ passed down the call chain starting at the
# end user invocation.
Expand Down
28 changes: 14 additions & 14 deletions lib/chrono_model/patches/relation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@ def merge(*)
super.as_of_time!(@_as_of_time)
end

def find_nth(*)
return super unless try(:history?)

with_hid_pkey { super }
end

def last(*)
return super unless try(:history?)

with_hid_pkey { super }
end

private

def build_arel(*)
return super unless @_as_of_time

Expand Down Expand Up @@ -70,20 +84,6 @@ def chrono_join_history(join)
)
end

def find_nth(*)
return super unless try(:history?)

with_hid_pkey { super }
end

def last(*)
return super unless try(:history?)

with_hid_pkey { super }
end

private

def ordered_relation
return super unless try(:history?)

Expand Down

0 comments on commit cf544ce

Please sign in to comment.