Class: Ohm::Model
- Inherits:
-
Object
- Object
- Ohm::Model
- Defined in:
- lib/active_resource_test_helper/ohm/model.rb
Overview
Adds some convenience methods to Ohm::Model.
Class Method Summary collapse
-
.count ⇒ Object
Return the number of instances of this model saved into redis.
-
.destroy_all ⇒ Object
Destroy all instances of this model.
Instance Method Summary collapse
-
#to_hash ⇒ Object
Convert the model to hash.
Class Method Details
.count ⇒ Object
Return the number of instances of this model saved into redis
23 24 25 |
# File 'lib/active_resource_test_helper/ohm/model.rb', line 23 def self.count self.all.size end |
.destroy_all ⇒ Object
Destroy all instances of this model
16 17 18 19 20 |
# File 'lib/active_resource_test_helper/ohm/model.rb', line 16 def self.destroy_all self.all.each do |i| i.delete end end |
Instance Method Details
#to_hash ⇒ Object
Convert the model to hash.
7 8 9 10 11 12 13 |
# File 'lib/active_resource_test_helper/ohm/model.rb', line 7 def to_hash hash = {:id => self.id.to_i} self.attributes.each do |attr| hash[attr] = self.send attr end hash end |