Module: Elastictastic::Persistence
- Defined in:
- lib/elastictastic/persistence.rb
Instance Method Summary collapse
- #destroy(options = {}, &block) ⇒ Object
- #pending_destroy! ⇒ Object
- #pending_destroy? ⇒ Boolean
- #pending_save! ⇒ Object
- #pending_save? ⇒ Boolean
- #persisted! ⇒ Object
- #persisted? ⇒ Boolean
- #save(options = {}, &block) ⇒ Object
- #transient! ⇒ Object
- #transient? ⇒ Boolean
Instance Method Details
#destroy(options = {}, &block) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/elastictastic/persistence.rb', line 7 def destroy( = {}, &block) if persisted? Elastictastic.persister.destroy(self, &block) else raise OperationNotAllowed, "Cannot destroy transient document: #{inspect}" end end |
#pending_destroy! ⇒ Object
44 45 46 |
# File 'lib/elastictastic/persistence.rb', line 44 def pending_destroy! @_pending_destroy = true end |
#pending_destroy? ⇒ Boolean
27 28 29 |
# File 'lib/elastictastic/persistence.rb', line 27 def pending_destroy? !!@_pending_destroy end |
#pending_save! ⇒ Object
40 41 42 |
# File 'lib/elastictastic/persistence.rb', line 40 def pending_save! @_pending_save = true end |
#pending_save? ⇒ Boolean
23 24 25 |
# File 'lib/elastictastic/persistence.rb', line 23 def pending_save? !!@_pending_save end |
#persisted! ⇒ Object
31 32 33 34 |
# File 'lib/elastictastic/persistence.rb', line 31 def persisted! @_persisted = true @_pending_save = false end |
#persisted? ⇒ Boolean
15 16 17 |
# File 'lib/elastictastic/persistence.rb', line 15 def persisted? !!@_persisted end |
#save(options = {}, &block) ⇒ Object
3 4 5 |
# File 'lib/elastictastic/persistence.rb', line 3 def save( = {}, &block) persisted? ? update(, &block) : create(, &block) end |
#transient! ⇒ Object
36 37 38 |
# File 'lib/elastictastic/persistence.rb', line 36 def transient! @_persisted = @_pending_destroy = false end |
#transient? ⇒ Boolean
19 20 21 |
# File 'lib/elastictastic/persistence.rb', line 19 def transient? !persisted? end |