Module: CouchPotato::Persistence::Json

Defined in:
lib/couch_potato/persistence/json.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



4
5
6
# File 'lib/couch_potato/persistence/json.rb', line 4

def self.included(base)
  base.extend ClassMethods
end

Instance Method Details

#to_hashObject



12
13
14
15
16
17
# File 'lib/couch_potato/persistence/json.rb', line 12

def to_hash
  (self.class.properties).inject({}) do |props, property|
    property.serialize(props, self)
    props
  end.merge('ruby_class' => self.class.name).merge(id_and_rev_json)
end

#to_json(*args) ⇒ Object



8
9
10
# File 'lib/couch_potato/persistence/json.rb', line 8

def to_json(*args)
  to_hash.to_json(*args)
end