module ScopedAssociations::ActiveRecord5::HasOne::ReflectionExtension
Public Instance Methods
association_class()
click to toggle source
# File lib/scoped_associations/activerecord5/has_one.rb, line 49 def association_class ScopedHasOneAssociation end
foreign_scope()
click to toggle source
# File lib/scoped_associations/activerecord5/has_one.rb, line 29 def foreign_scope if options[:as] "#{options[:as]}_scope" else name = active_record.name name.demodulize.underscore + "_scope" end end
scope()
click to toggle source
Calls superclass method
# File lib/scoped_associations/activerecord5/has_one.rb, line 38 def scope old_scope = super scope_conditions = { foreign_scope => name } proc_scope = proc { where(scope_conditions) } if old_scope.nil? proc { instance_eval(&proc_scope) } else proc { instance_eval(&proc_scope).instance_eval(&old_scope) } end end