class AttributesHistory::HistoryRetriever
Public Class Methods
new(object)
click to toggle source
# File lib/attributes_history/history_retriever.rb, line 3 def initialize(object) @object = object @cached_history = {} end
Public Instance Methods
attribute_on_date(attribute, date)
click to toggle source
# File lib/attributes_history/history_retriever.rb, line 8 def attribute_on_date(attribute, date) history_association = @object.class.history_association(attribute) history_entry = @cached_history[[history_association, date]] ||= find_entry_on(history_association, date) history_entry.public_send(attribute) end
Private Instance Methods
find_entry_on(history_association, date)
click to toggle source
# File lib/attributes_history/history_retriever.rb, line 19 def find_entry_on(history_association, date) @object.public_send(history_association) .where('recorded_on > ?', date).order(:recorded_on).first || @object end