Class: Sliver::Endpoints

Inherits:
Object
  • Object
show all
Defined in:
lib/sliver/endpoints.rb

Instance Method Summary collapse

Constructor Details

#initializeEndpoints

Returns a new instance of Endpoints.



4
5
6
# File 'lib/sliver/endpoints.rb', line 4

def initialize
  @paths = {}
end

Instance Method Details

#append(path, action) ⇒ Object



8
9
10
# File 'lib/sliver/endpoints.rb', line 8

def append(path, action)
  paths[path] = action
end

#find(environment) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/sliver/endpoints.rb', line 12

def find(environment)
  path = paths.keys.detect { |key| key.matches?(environment) }
  return nil unless path

  environment[Sliver::PATH_KEY] = path
  paths[path]
end