Sha256: f661f76c880ef23f2bb7b1e8bba590bea8c5bae141daa441d3e44eb77146695f

Contents?: true

Size: 458 Bytes

Versions: 2

Compression:

Stored size: 458 Bytes

Contents

module CouchPotato
  module GhostAttributes #:nodoc:
    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
    
    def method_missing(name, *args)
      if(value = _document && _document[name.to_s])
        value
      else
        super
      end
    end
    
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
couch_potato-0.3.2 lib/couch_potato/persistence/ghost_attributes.rb
couch_potato-0.3.1 lib/couch_potato/persistence/ghost_attributes.rb