Class: AnotherApi::Scopes::DSL
- Inherits:
-
Object
- Object
- AnotherApi::Scopes::DSL
- Defined in:
- lib/another_api/scopes.rb
Instance Method Summary collapse
-
#initialize(scopes_class) ⇒ DSL
constructor
A new instance of DSL.
- #scope(group, only: %i[list show create update delete])) ⇒ Object
Constructor Details
#initialize(scopes_class) ⇒ DSL
Returns a new instance of DSL.
27 28 29 |
# File 'lib/another_api/scopes.rb', line 27 def initialize(scopes_class) @scopes_class = scopes_class end |
Instance Method Details
#scope(group, only: %i[list show create update delete])) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/another_api/scopes.rb', line 31 def scope(group, only: %i[list show create update delete]) @scopes_class.registry[:"#{group}.all"] = Scope.new(group: group, action: :all) only.each do |action| @scopes_class.registry[:"#{group}.#{action}"] = Scope.new(group: group, action: action) end rescue ArgumentError => e raise ArgumentError, "scope :#{group} — #{e.}" end |