Class: Rack::JsonWebTokenAuth::Resources
- Inherits:
-
Object
- Object
- Rack::JsonWebTokenAuth::Resources
- Includes:
- Contracts::Core
- Defined in:
- lib/rack/json_web_token_auth/resources.rb
Constant Summary collapse
- C =
Contracts
Instance Method Summary collapse
-
#initialize(public_resource: false) ⇒ Resources
constructor
A new instance of Resources.
- #public_resource? ⇒ Boolean
- #resource(path, opts = {}) ⇒ Object
- #resource_for_path(path) ⇒ Object
Constructor Details
#initialize(public_resource: false) ⇒ Resources
Returns a new instance of Resources.
11 12 13 14 |
# File 'lib/rack/json_web_token_auth/resources.rb', line 11 def initialize(public_resource: false) @resources = [] @public_resource = public_resource end |
Instance Method Details
#public_resource? ⇒ Boolean
17 18 19 |
# File 'lib/rack/json_web_token_auth/resources.rb', line 17 def public_resource? @public_resource end |
#resource(path, opts = {}) ⇒ Object
22 23 24 |
# File 'lib/rack/json_web_token_auth/resources.rb', line 22 def resource(path, opts = {}) @resources << Resource.new(public_resource?, path, opts) end |
#resource_for_path(path) ⇒ Object
27 28 29 30 |
# File 'lib/rack/json_web_token_auth/resources.rb', line 27 def resource_for_path(path) # return first match @resources.detect { |r| r.matches_path?(path) } end |