method
new
v4.0.2 -
Show latest stable
- Class:
ActiveRecord::Associations::Builder::Association
new(model, name, scope, options)public
No documentation available.
# File activerecord/lib/active_record/associations/builder/association.rb, line 15
def initialize(model, name, scope, options)
raise ArgumentError, "association names must be a Symbol" unless name.kind_of?(Symbol)
@model = model
@name = name
if scope.is_a?(Hash)
@scope = nil
@options = scope
else
@scope = scope
@options = options
end
if @scope && @scope.arity == 0
prev_scope = @scope
@scope = proc { instance_exec(&prev_scope) }
end
end