Module: Spyke::Orm
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #destroy ⇒ Object
- #persisted? ⇒ Boolean
- #reload ⇒ Object
- #save ⇒ Object
- #to_params ⇒ Object
- #update(new_attributes) ⇒ Object (also: #update_attributes)
Instance Method Details
#destroy ⇒ Object
74 75 76 |
# File 'lib/spyke/orm.rb', line 74 def destroy self.attributes = delete end |
#persisted? ⇒ Boolean
61 62 63 |
# File 'lib/spyke/orm.rb', line 61 def persisted? id? end |
#reload ⇒ Object
84 85 86 |
# File 'lib/spyke/orm.rb', line 84 def reload self.attributes = self.class.find(id).attributes end |
#save ⇒ Object
65 66 67 68 69 70 71 72 |
# File 'lib/spyke/orm.rb', line 65 def save run_callbacks :save do callback = persisted? ? :update : :create run_callbacks(callback) do send self.class.method_for(callback), to_params end end end |
#to_params ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/spyke/orm.rb', line 53 def to_params if param_root { param_root => } else end end |
#update(new_attributes) ⇒ Object Also known as: update_attributes
78 79 80 81 |
# File 'lib/spyke/orm.rb', line 78 def update(new_attributes) self.attributes = new_attributes save end |