Module: Tire::Model::Persistence::Storage::InstanceMethods
- Defined in:
- lib/tire/model/persistence/storage.rb
Instance Method Summary collapse
- #destroy ⇒ Object
- #destroyed? ⇒ Boolean
- #new_record? ⇒ Boolean
- #persisted? ⇒ Boolean
- #save ⇒ Object
- #update_attribute(name, value) ⇒ Object
- #update_attributes(attributes = {}) ⇒ Object
Instance Method Details
#destroy ⇒ Object
51 52 53 54 55 56 |
# File 'lib/tire/model/persistence/storage.rb', line 51 def destroy run_callbacks :destroy do @destroyed = true end self.freeze end |
#destroyed? ⇒ Boolean
58 |
# File 'lib/tire/model/persistence/storage.rb', line 58 def destroyed? ; !!@destroyed; end |
#new_record? ⇒ Boolean
60 |
# File 'lib/tire/model/persistence/storage.rb', line 60 def new_record? ; !persisted?; end |
#persisted? ⇒ Boolean
59 |
# File 'lib/tire/model/persistence/storage.rb', line 59 def persisted? ; !!id && !!_version; end |
#save ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/tire/model/persistence/storage.rb', line 42 def save return false unless valid? run_callbacks :save do # Document#id is set in the +update_elasticsearch_index+ method, # where we have access to the JSON response end self end |
#update_attribute(name, value) ⇒ Object
32 33 34 35 |
# File 'lib/tire/model/persistence/storage.rb', line 32 def update_attribute(name, value) __update_attributes name => value save end |
#update_attributes(attributes = {}) ⇒ Object
37 38 39 40 |
# File 'lib/tire/model/persistence/storage.rb', line 37 def update_attributes(attributes={}) __update_attributes attributes save end |