Module: CassandraModel::Persistence::InstanceMethods
- Defined in:
- lib/cassandra-model/persistence.rb
Instance Method Summary collapse
- #destroy ⇒ Object
- #reload ⇒ Object
- #remove_attributes(attrs) ⇒ Object
- #save ⇒ Object
- #update_attributes(attrs) ⇒ Object
Instance Method Details
#destroy ⇒ Object
19 20 21 22 23 |
# File 'lib/cassandra-model/persistence.rb', line 19 def destroy run_callbacks :destroy do self.class.remove(key) end end |
#reload ⇒ Object
25 26 27 |
# File 'lib/cassandra-model/persistence.rb', line 25 def reload self.class.get(key) end |
#remove_attributes(attrs) ⇒ Object
34 35 36 |
# File 'lib/cassandra-model/persistence.rb', line 34 def remove_attributes(attrs) attrs.each {|attr| self.class.remove_column(key, attr) } end |
#save ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/cassandra-model/persistence.rb', line 9 def save return self unless valid? run_callbacks :save do callback = new_record? ? :create : :update run_callbacks callback do write(attributes) end end end |
#update_attributes(attrs) ⇒ Object
29 30 31 32 |
# File 'lib/cassandra-model/persistence.rb', line 29 def update_attributes(attrs) self.attributes = attrs save end |