Class: JsonapiCompliable::Scope::Base
- Inherits:
-
Object
- Object
- JsonapiCompliable::Scope::Base
- Defined in:
- lib/jsonapi_compliable/scope/base.rb
Instance Attribute Summary collapse
-
#controller ⇒ Object
readonly
Returns the value of attribute controller.
-
#dsl ⇒ Object
readonly
Returns the value of attribute dsl.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
Instance Method Summary collapse
- #apply ⇒ Object
- #apply_custom_scope ⇒ Object
- #apply_standard_or_override ⇒ Object
- #apply_standard_scope ⇒ Object
- #apply_standard_scope? ⇒ Boolean
-
#initialize(controller, scope) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(controller, scope) ⇒ Base
Returns a new instance of Base.
6 7 8 9 10 11 |
# File 'lib/jsonapi_compliable/scope/base.rb', line 6 def initialize(controller, scope) @controller = controller @dsl = controller._jsonapi_compliable @params = controller.params @scope = scope end |
Instance Attribute Details
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
4 5 6 |
# File 'lib/jsonapi_compliable/scope/base.rb', line 4 def controller @controller end |
#dsl ⇒ Object (readonly)
Returns the value of attribute dsl.
4 5 6 |
# File 'lib/jsonapi_compliable/scope/base.rb', line 4 def dsl @dsl end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
4 5 6 |
# File 'lib/jsonapi_compliable/scope/base.rb', line 4 def params @params end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
4 5 6 |
# File 'lib/jsonapi_compliable/scope/base.rb', line 4 def scope @scope end |
Instance Method Details
#apply ⇒ Object
13 14 15 |
# File 'lib/jsonapi_compliable/scope/base.rb', line 13 def apply apply_standard_or_override end |
#apply_custom_scope ⇒ Object
35 36 37 |
# File 'lib/jsonapi_compliable/scope/base.rb', line 35 def apply_custom_scope raise 'override in subclass' end |
#apply_standard_or_override ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/jsonapi_compliable/scope/base.rb', line 17 def apply_standard_or_override if apply_standard_scope? @scope = apply_standard_scope else @scope = apply_custom_scope end @scope end |
#apply_standard_scope ⇒ Object
31 32 33 |
# File 'lib/jsonapi_compliable/scope/base.rb', line 31 def apply_standard_scope raise 'override in subclass' end |
#apply_standard_scope? ⇒ Boolean
27 28 29 |
# File 'lib/jsonapi_compliable/scope/base.rb', line 27 def apply_standard_scope? custom_scope.nil? end |