Module: Slingshot::Model::Persistence::Storage::InstanceMethods
- Defined in:
- lib/slingshot/model/persistence/storage.rb
Instance Method Summary collapse
- #destroy ⇒ Object
-
#destroyed? ⇒ Boolean
TODO: Implement ‘new_record?` and clean up.
- #persisted? ⇒ Boolean
- #save ⇒ Object
- #update_attribute(name, value) ⇒ Object
- #update_attributes(attributes = {}) ⇒ Object
Instance Method Details
#destroy ⇒ Object
55 56 57 58 59 60 |
# File 'lib/slingshot/model/persistence/storage.rb', line 55 def destroy run_callbacks :destroy do @destroyed = true end self.freeze end |
#destroyed? ⇒ Boolean
TODO: Implement ‘new_record?` and clean up
64 |
# File 'lib/slingshot/model/persistence/storage.rb', line 64 def destroyed?; !!@destroyed; end |
#persisted? ⇒ Boolean
66 |
# File 'lib/slingshot/model/persistence/storage.rb', line 66 def persisted?; !!id; end |
#save ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/slingshot/model/persistence/storage.rb', line 46 def save return false unless valid? run_callbacks :save do # Document#id is set in the +update_elastic_search_index+ method, # where we have access to the JSON response end self end |
#update_attribute(name, value) ⇒ Object
34 35 36 37 |
# File 'lib/slingshot/model/persistence/storage.rb', line 34 def update_attribute(name, value) send("#{name}=", value) save end |
#update_attributes(attributes = {}) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/slingshot/model/persistence/storage.rb', line 39 def update_attributes(attributes={}) attributes.each do |name, value| send("#{name}=", value) end save end |