Module: Cuprum::Collections::Relations::Scope
- Included in:
- Collection, Cuprum::Collections::Resource
- Defined in:
- lib/cuprum/collections/relations/scope.rb
Overview
Methods for defining a scope for a relation.
Instance Attribute Summary collapse
-
#scope ⇒ Cuprum::Collections::Scopes::Base
readonly
The configured scope for the relation.
Instance Method Summary collapse
Instance Attribute Details
#scope ⇒ Cuprum::Collections::Scopes::Base
Returns the configured scope for the relation.
19 20 21 |
# File 'lib/cuprum/collections/relations/scope.rb', line 19 def scope @scope end |
Instance Method Details
#initialize(scope: nil, **) ⇒ Object
11 12 13 14 15 |
# File 'lib/cuprum/collections/relations/scope.rb', line 11 def initialize(scope: nil, **parameters) super(**parameters) @scope = apply_scope(default_scope, scope) end |
#with_scope(scope) ⇒ Cuprum::Collections::Relations::Scope #with_scope {|query| ... } ⇒ Cuprum::Collections::Relations::Scope
41 42 43 |
# File 'lib/cuprum/collections/relations/scope.rb', line 41 def with_scope(value = nil, &block) dup.tap { |copy| copy.scope = apply_scope(scope, value || block) } end |