Module: ScopedAssociations::ActiveRecord5::HasOne
- Defined in:
- lib/scoped_associations/activerecord5/has_one.rb
Defined Under Namespace
Modules: ReflectionExtension
Classes: ScopedHasOneAssociation
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_one.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_one.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_one.rb', line 4
def valid_options(options)
super + [:scoped]
end
|