Class: Typekit::Routing::Node::Operation
- Defined in:
- lib/typekit/routing/node/operation.rb
Instance Method Summary collapse
-
#initialize(name, action:, on:, **options) ⇒ Operation
constructor
A new instance of Operation.
- #match(name) ⇒ Object
- #permitted?(request) ⇒ Boolean
- #process(request, path) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(name, action:, on:, **options) ⇒ Operation
Returns a new instance of Operation.
5 6 7 8 9 10 11 12 |
# File 'lib/typekit/routing/node/operation.rb', line 5 def initialize(name, action:, on:, **) # TODO: how about on == :collection? unless Typekit.actions.include?(action) && on == :member raise Error, 'Not supported' end @name = name @action = action end |
Instance Method Details
#match(name) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/typekit/routing/node/operation.rb', line 14 def match(name) if @name.is_a?(String) && @name =~ /^:/ true else @name == name end end |
#permitted?(request) ⇒ Boolean
26 27 28 |
# File 'lib/typekit/routing/node/operation.rb', line 26 def permitted?(request) @action == request.action end |
#process(request, path) ⇒ Object
22 23 24 |
# File 'lib/typekit/routing/node/operation.rb', line 22 def process(request, path) request << path.shift # @name end |