Class: AttributesHistory::HistoryRetriever
- Inherits:
-
Object
- Object
- AttributesHistory::HistoryRetriever
- Defined in:
- lib/attributes_history/history_retriever.rb
Instance Method Summary collapse
- #attribute_on_date(attribute, date) ⇒ Object
-
#initialize(object) ⇒ HistoryRetriever
constructor
A new instance of HistoryRetriever.
Constructor Details
#initialize(object) ⇒ HistoryRetriever
Returns a new instance of HistoryRetriever.
5 6 7 8 |
# File 'lib/attributes_history/history_retriever.rb', line 5 def initialize(object) @object = object @cached_history = {} end |
Instance Method Details
#attribute_on_date(attribute, date) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/attributes_history/history_retriever.rb', line 10 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 |