class ActiveRecord::Associations::Builder::DeprecatedOptionsProc - activerecord-deprecated_finders-1.0.3 Documentation

# class ActiveRecord::Associations::Builder::DeprecatedOptionsProc

### Attributes

options[R]

### Public Class Methods

new(options) click to toggle source

    # File lib/active_record/deprecated_finders/association_builder.rb, line 9
    def initialize(options)
      options[:includes]  = options.delete(:include)    if options[:include]
      options[:where]     = options.delete(:conditions) if options[:conditions]

      @options = options
    end

### Public Instance Methods

arity() click to toggle source

    # File lib/active_record/deprecated_finders/association_builder.rb, line 29
    def arity
      1
    end

to_proc() click to toggle source

    # File lib/active_record/deprecated_finders/association_builder.rb, line 16
    def to_proc
      options = self.options
      proc do |owner|
        if options[:where].respond_to?(:to_proc)
          context = owner || self
          where(context.instance_eval(&options[:where]))
            .merge!(options.except(:where))
        else
          merge(options)
        end
      end
    end