Module: Godmin::Resources::ResourceService::Scopes
- Extended by:
- ActiveSupport::Concern
- Included in:
- Godmin::Resources::ResourceService
- Defined in:
- lib/godmin/resources/resource_service/scopes.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #apply_scope(scope_param, resources) ⇒ Object
- #scope ⇒ Object
- #scope=(scope) ⇒ Object
- #scope_count(scope) ⇒ Object
- #scoped_by?(name) ⇒ Boolean
Instance Method Details
#apply_scope(scope_param, resources) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/godmin/resources/resource_service/scopes.rb', line 9 def apply_scope(scope_param, resources) return resources if scope_map.empty? self.scope = scope_param if scope && scope_map.key?(scope.to_sym) send("scope_#{@scope}", resources) else fail NotImplementedError, "Scope #{@scope} not implemented" end end |
#scope ⇒ Object
25 26 27 |
# File 'lib/godmin/resources/resource_service/scopes.rb', line 25 def scope @scope end |
#scope=(scope) ⇒ Object
21 22 23 |
# File 'lib/godmin/resources/resource_service/scopes.rb', line 21 def scope=(scope) @scope = scope.blank? ? default_scope : scope end |
#scope_count(scope) ⇒ Object
33 34 35 |
# File 'lib/godmin/resources/resource_service/scopes.rb', line 33 def scope_count(scope) send("scope_#{scope}", resources_relation).count end |
#scoped_by?(name) ⇒ Boolean
29 30 31 |
# File 'lib/godmin/resources/resource_service/scopes.rb', line 29 def scoped_by?(name) @scope == name.to_s end |