Sha256: d218e94779419372d9673d648566e0e7b3fc2c5befc0d9295e54b9d049b6fd41

Contents?: true

Size: 990 Bytes

Versions: 11

Compression:

Stored size: 990 Bytes

Contents

# encoding: utf-8
module Mongoid #:nodoc
  module Associations #:nodoc
    class Proxy #:nodoc
      instance_methods.each do |method|
        undef_method(method) unless method =~ /(^__|^nil\?$|^send$|^object_id$|^extend$)/
      end
      attr_reader \
        :options,
        :target

      # Default behavior of method missing should be to delegate all calls
      # to the target of the proxy. This can be overridden in special cases.
      def method_missing(name, *args, &block)
        @target.send(name, *args, &block)
      end

      # If anonymous extensions are added this will take care of them.
      def extends(options)
        extend Module.new(&options.extension) if options.extension?
      end

      # Sets up the parent, klass, foreign_key, options
      def setup(document, options)
        @parent = document
        @klass = options.klass
        @options = options
        @foreign_key = options.foreign_key
        extends(options)
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 3 rubygems

Version Path
mongoid-2.0.0.beta.15 lib/mongoid/associations/proxy.rb
mongoid-2.0.0.beta.14 lib/mongoid/associations/proxy.rb
mongoid-2.0.0.beta.13 lib/mongoid/associations/proxy.rb
mongoid-2.0.0.beta.11 lib/mongoid/associations/proxy.rb
mongoid-2.0.0.beta.10 lib/mongoid/associations/proxy.rb
mongoid-2.0.0.beta.7 lib/mongoid/associations/proxy.rb
mongoid-2.0.0.beta.8 lib/mongoid/associations/proxy.rb
mongoid-2.0.0.beta.9 lib/mongoid/associations/proxy.rb
mongoid-2.0.0.beta.12 lib/mongoid/associations/proxy.rb
mongoid-locomotive-2.0.0.beta9 lib/mongoid/associations/proxy.rb
chhean-mongoid-2.0.1.beta1 lib/mongoid/associations/proxy.rb