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



18
19
20
21
22
23
24
# File 'lib/couch_potato/persistence/ghost_attributes.rb', line 18

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
13
14
15
16
# 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_with_ghost(json)
      instance = json_create_without_ghost(json)
      instance._document = json if json
      instance
    end
    
    class << self
      alias_method_chain :json_create, :ghost
    end
  end
end