Module: CouchPotato::GhostAttributes

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

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/couch_potato/persistence/ghost_attributes.rb', line 3

def self.included(base)
  base.class_eval do
    attr_accessor :_document
    def self.json_create(json)
      instance = super
      instance._document = json if json
      instance
    end
    
    def method_missing(name, *args)
      if(value = _document && _document[name.to_s])
        value
      else
        super
      end
    end
  end
end