class Apitizer::Routing::Map
Public Class Methods
new(&block)
click to toggle source
# File lib/apitizer/routing/map.rb, line 8 def initialize(&block) @root = Node::Root.new define(&block) if block_given? end
Public Instance Methods
define(&block)
click to toggle source
# File lib/apitizer/routing/map.rb, line 19 def define(&block) proxy = Proxy.new(self) proxy.instance_eval(&block) end
define_resources(name, options, &block)
click to toggle source
# File lib/apitizer/routing/map.rb, line 24 def define_resources(name, options, &block) parent = options.delete(:parent) || @root child = Node::Collection.new(name, options) parent.append(child) return unless block_given? proxy = Proxy.new(self, parent: child) proxy.instance_eval(&block) end
trace(action, *arguments)
click to toggle source
# File lib/apitizer/routing/map.rb, line 13 def trace(action, *arguments) path = @root.trace(*arguments) or raise Error, 'Not found' raise Error, 'Not permitted' unless path.permit?(action) path end