Sha256: 3886358596a284110f8f5661ed45db6e05145f8b42c04fca6b54b2414f967151

Contents?: true

Size: 585 Bytes

Versions: 2

Compression:

Stored size: 585 Bytes

Contents

module CouchPotato
  module GhostAttributes #:nodoc:
    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
    
    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 & 2 rubygems

Version Path
davber_couch_potato-0.4.0 lib/couch_potato/persistence/ghost_attributes.rb
couch_potato-0.4.0 lib/couch_potato/persistence/ghost_attributes.rb