Class: AssociationScope::Scope
- Inherits:
-
Object
- Object
- AssociationScope::Scope
- Defined in:
- lib/association_scope/scope.rb,
lib/association_scope/scope/has_one_reflection.rb,
lib/association_scope/scope/through_reflection.rb,
lib/association_scope/scope/has_many_reflection.rb,
lib/association_scope/scope/belongs_to_reflection.rb,
lib/association_scope/scope/has_and_belongs_to_many_reflection.rb
Direct Known Subclasses
BelongsToReflection, HasAndBelongsToManyReflection, HasManyReflection, ThroughReflection
Defined Under Namespace
Classes: BelongsToReflection, HasAndBelongsToManyReflection, HasManyReflection, HasOneReflection, ThroughReflection
Instance Attribute Summary collapse
-
#association ⇒ Object
readonly
Returns the value of attribute association.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(model, association) ⇒ Scope
constructor
A new instance of Scope.
Constructor Details
#initialize(model, association) ⇒ Scope
Returns a new instance of Scope.
7 8 9 10 |
# File 'lib/association_scope/scope.rb', line 7 def initialize(model, association) @model = model @association = association end |
Instance Attribute Details
#association ⇒ Object (readonly)
Returns the value of attribute association.
5 6 7 |
# File 'lib/association_scope/scope.rb', line 5 def association @association end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
5 6 7 |
# File 'lib/association_scope/scope.rb', line 5 def model @model end |
Class Method Details
.inject_scopes(model, reflections) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/association_scope/scope.rb', line 12 def self.inject_scopes(model, reflections) model.reflections.slice(*reflections).each do |association, details| scope_type = details.class.to_s.split("::").last "AssociationScope::Scope::#{scope_type}".constantize.new(model, association).apply end end |