Class: Service::Client::RouteCollection

Inherits:
Object
  • Object
show all
Defined in:
lib/service-client/route_collection.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object (protected)



14
15
16
17
# File 'lib/service-client/route_collection.rb', line 14

def method_missing(name, *args)
  raise Service::Client::RoutingError.new("No route named #{name}") unless route = routes[name.to_sym]
  route.bind(*args)
end

Instance Method Details

#add(name, method, pattern) ⇒ Object



2
3
4
5
6
7
# File 'lib/service-client/route_collection.rb', line 2

def add(name, method, pattern)
  name = name.to_sym

  route = routes[name] ||= Service::Client::Route.new
  route.add_pattern(method, pattern)
end