Module: CouchTomato::Persistence::Nested
- Includes:
- Base
- Defined in:
- lib/couch_tomato/persistence.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
-
#to_hash ⇒ Object
returns all the attributes, the ruby class and the _id and _rev of a model as a Hash.
- #to_json(*args) ⇒ Object
Methods included from Base
#==, #attributes, #attributes=, #initialize
Class Method Details
.included(base) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/couch_tomato/persistence.rb', line 18 def self.included(base) base.send :include, Properties, Callbacks, Validation#, Json#, CouchTomato::View::CustomViews # base.send :include, DirtyAttributes # base.send :include, MagicTimestamps base.extend ClassMethods end |
Instance Method Details
#to_hash ⇒ Object
returns all the attributes, the ruby class and the _id and _rev of a model as a Hash
32 33 34 35 36 37 |
# File 'lib/couch_tomato/persistence.rb', line 32 def to_hash (self.class.properties).inject({}) do |props, property| property.serialize(props, self) props end end |
#to_json(*args) ⇒ Object
26 27 28 29 |
# File 'lib/couch_tomato/persistence.rb', line 26 def to_json(*args) to_hash.to_json(*args) # to_json(*args) end |