Module: CouchPotato::GhostAttributes

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

Overview

:nodoc:

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/couch_potato/persistence/ghost_attributes.rb', line 14

def method_missing(name, *args)
  if(value = _document && _document[name.to_s])
    value
  else
    super
  end
end

Class Method Details

.included(base) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# 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
  end
end