Class: Vault::Scoping::Scope
- Inherits:
-
Object
- Object
- Vault::Scoping::Scope
- Includes:
- Finders
- Defined in:
- lib/vault/scoping.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#conditions ⇒ Object
readonly
Returns the value of attribute conditions.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Instance Method Summary collapse
-
#initialize(model, conditions) ⇒ Scope
constructor
A new instance of Scope.
- #method_missing(method) ⇒ Object
- #respond_to?(method, include_private = false) ⇒ Boolean
- #store ⇒ Object
Methods included from Finders
Constructor Details
#initialize(model, conditions) ⇒ Scope
Returns a new instance of Scope.
32 33 34 35 |
# File 'lib/vault/scoping.rb', line 32 def initialize(model, conditions) @model = model @conditions = conditions.stringify_keys end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/vault/scoping.rb', line 41 def method_missing(method, *) if model_has_scope?(method) merge(model.scopes[method.to_s]) else super end end |
Instance Attribute Details
#conditions ⇒ Object (readonly)
Returns the value of attribute conditions.
30 31 32 |
# File 'lib/vault/scoping.rb', line 30 def conditions @conditions end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
30 31 32 |
# File 'lib/vault/scoping.rb', line 30 def model @model end |
Instance Method Details
#respond_to?(method, include_private = false) ⇒ Boolean
49 50 51 |
# File 'lib/vault/scoping.rb', line 49 def respond_to?(method, include_private=false) model_has_scope?(method) || super end |
#store ⇒ Object
37 38 39 |
# File 'lib/vault/scoping.rb', line 37 def store @store ||= @model.store.filter(conditions) end |