class Cynic::Routing
Public Class Methods
new()
click to toggle source
# File lib/cynic/routing.rb, line 18 def initialize() @routings = { get: Cynic::RouteOption.new, post: Cynic::RouteOption.new, patch: Cynic::RouteOption.new, delete: Cynic::RouteOption.new } end
Public Instance Methods
action(request_method, request_path)
click to toggle source
# File lib/cynic/routing.rb, line 41 def action(request_method, request_path) @routings[request_method.to_sym][request_path] end
define(&block)
click to toggle source
# File lib/cynic/routing.rb, line 27 def define(&block) block.call(self).to_s self end
get(path, options={})
click to toggle source
# File lib/cynic/routing.rb, line 45 def get(path, options={}) @routings[:get][path] = options[:to] end
go_to(request_method, request_path)
click to toggle source
# File lib/cynic/routing.rb, line 32 def go_to(request_method, request_path) route = action(request_method, request_path) if route route else raise Error, "undefined routing #{request_method.upcase} '#{request_path}'" end end
post(path, options={})
click to toggle source
# File lib/cynic/routing.rb, line 49 def post(path, options={}) @routings[:post][path] = options[:to] end