Class: ROM::Session::Tracker Private
- Inherits:
-
Object
- Object
- ROM::Session::Tracker
- Defined in:
- lib/rom/session/tracker.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
- #clean? ⇒ Boolean private
- #commit ⇒ Object private
- #fetch(object) ⇒ Object private
- #include?(object) ⇒ Boolean private
-
#initialize ⇒ Tracker
constructor
private
A new instance of Tracker.
- #queue(state) ⇒ Object private
- #store_persisted(object, mapper) ⇒ Object private
- #store_transient(object, mapper) ⇒ Object private
- #update(state) ⇒ Object private
Constructor Details
#initialize ⇒ Tracker
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Tracker.
12 13 14 15 |
# File 'lib/rom/session/tracker.rb', line 12 def initialize @objects = {} @changelog = [] end |
Instance Method Details
#clean? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
34 35 36 |
# File 'lib/rom/session/tracker.rb', line 34 def clean? changelog.empty? end |
#commit ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
18 19 20 21 |
# File 'lib/rom/session/tracker.rb', line 18 def commit @changelog.each { |state| update(state.commit) } @changelog = [] end |
#fetch(object) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
24 25 26 |
# File 'lib/rom/session/tracker.rb', line 24 def fetch(object) @objects.fetch(object.__id__) { raise ObjectNotTrackedError, object } end |
#include?(object) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
29 30 31 |
# File 'lib/rom/session/tracker.rb', line 29 def include?(object) @objects.key?(object.__id__) end |
#queue(state) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
39 40 41 42 |
# File 'lib/rom/session/tracker.rb', line 39 def queue(state) @changelog << state update(state) end |
#store_persisted(object, mapper) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
55 56 57 |
# File 'lib/rom/session/tracker.rb', line 55 def store_persisted(object, mapper) store(object, State::Persisted.new(object, mapper)) end |
#store_transient(object, mapper) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
50 51 52 |
# File 'lib/rom/session/tracker.rb', line 50 def store_transient(object, mapper) store(object, State::Transient.new(object, mapper)) end |
#update(state) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
45 46 47 |
# File 'lib/rom/session/tracker.rb', line 45 def update(state) store(state.object, state) end |