Class: Typekit::Routing::Node::Operation

Inherits:
Base
  • Object
show all
Defined in:
lib/typekit/routing/node/operation.rb

Instance Method Summary collapse

Methods inherited from Base

#append, #assemble

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:, **options)
  # 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

Returns:

  • (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