class Shackleton::Builder
Public Instance Methods
add_route(route, kwargs)
click to toggle source
# File lib/shackleton/builder.rb, line 15 def add_route(route, kwargs) stack << Shackleton::Fragment.new(route, kwargs) self end
build()
click to toggle source
# File lib/shackleton/builder.rb, line 11 def build [stack.map(&:call).compact.join('/').gsub(%r{/+}, '/'), query_params].reject(&:empty?).join("?") end
method_missing(method, *args, **kwargs, &block)
click to toggle source
Calls superclass method
# File lib/shackleton/builder.rb, line 24 def method_missing(method, *args, **kwargs, &block) return self.add_route(stack.last[method.to_sym], kwargs) if stack.last[method.to_sym] super end
query_params()
click to toggle source
# File lib/shackleton/builder.rb, line 20 def query_params URI.encode_www_form(Hash[*stack.map {|x| x.query_params.to_a}.flatten]) end
stack()
click to toggle source
# File lib/shackleton/builder.rb, line 7 def stack @stack ||= [] end