Module: ScopedAssociations::ActiveRecord5::HasManyClassMethods

Defined in:
lib/scoped_associations/activerecord5/has_many.rb

Defined Under Namespace

Modules: ReflectionExtension Classes: ScopedHasManyAssociation

Instance Method Summary collapse

Instance Method Details

#build(model, name, scope, options, &block) ⇒ Object



8
9
10
11
12
# File 'lib/scoped_associations/activerecord5/has_many.rb', line 8

def build(model, name, scope, options, &block)
  reflection = super(model, name, scope, options, &block)
  extend_reflection(reflection)
  reflection
end

#extend_reflection(reflection) ⇒ Object



14
15
16
17
18
# File 'lib/scoped_associations/activerecord5/has_many.rb', line 14

def extend_reflection(reflection)
  if reflection.options[:scoped]
    reflection.extend ReflectionExtension
  end
end

#valid_options(options) ⇒ Object



4
5
6
# File 'lib/scoped_associations/activerecord5/has_many.rb', line 4

def valid_options(options)
  super + [:scoped]
end