Sha256: d906ba56bff967058ef3e1add1ad58142b75a4becd5fe26213ccefe6cf18b74f

Contents?: true

Size: 485 Bytes

Versions: 14

Compression:

Stored size: 485 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
        
        def method_missing(name, *args)
          if(value = _document && _document[name.to_s])
            value
          else
            super
          end
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
davber_couch_potato-0.3.0 lib/couch_potato/persistence/ghost_attributes.rb
couch_potato-0.3.0 lib/couch_potato/persistence/ghost_attributes.rb
couch_potato-0.2.32 lib/couch_potato/persistence/ghost_attributes.rb
couch_potato-0.2.31 lib/couch_potato/persistence/ghost_attributes.rb
couch_potato-0.2.30 lib/couch_potato/persistence/ghost_attributes.rb
couch_potato-0.2.29 lib/couch_potato/persistence/ghost_attributes.rb
couch_potato-0.2.28 lib/couch_potato/persistence/ghost_attributes.rb
couch_potato-0.2.27 lib/couch_potato/persistence/ghost_attributes.rb
couch_potato-0.2.26 lib/couch_potato/persistence/ghost_attributes.rb
couch_potato-0.2.25 lib/couch_potato/persistence/ghost_attributes.rb
couch_potato-0.2.24 lib/couch_potato/persistence/ghost_attributes.rb
couch_potato-0.2.23 lib/couch_potato/persistence/ghost_attributes.rb
couch_potato-0.2.22 lib/couch_potato/persistence/ghost_attributes.rb
couch_potato-0.2.21 lib/couch_potato/persistence/ghost_attributes.rb