Skip to content

Commit

Permalink
Merge pull request #245 from ifad/chore/use-delegate
Browse files Browse the repository at this point in the history
Use Rails' delegate
  • Loading branch information
tagliala authored Oct 19, 2023
2 parents fbb16fa + 5a2fae8 commit 5aedcdf
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 16 deletions.
7 changes: 0 additions & 7 deletions .rubocop_todo.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions lib/chrono_model/time_machine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,7 @@ def history?

# Returns an ActiveRecord::Relation on the history of this model as
# it was +time+ ago.
def as_of(time)
history.as_of(time)
end
delegate :as_of, to: :history

def attribute_names_for_history_changes
@attribute_names_for_history_changes ||= attribute_names -
Expand Down
8 changes: 2 additions & 6 deletions lib/chrono_model/time_machine/history_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,7 @@ def of(object)
#
# As such it is overriden here to return the same contents that
# the parent would have returned.
def sti_name
superclass.sti_name
end
delegate :sti_name, to: :superclass

# For STI to work, the history model needs to have the exact same
# semantics as the model it inherits from. However given it is
Expand All @@ -120,9 +118,7 @@ def sti_name
# same exact hierarchy location as its parent, thus this is defined in
# this override.
#
def descends_from_active_record?
superclass.descends_from_active_record?
end
delegate :descends_from_active_record?, to: :superclass

private

Expand Down

0 comments on commit 5aedcdf

Please sign in to comment.