module Roda::RodaPlugins::Path::InstanceMethods
def _base_url
def _base_url r = @_request scheme = r.scheme port = r.port "#{scheme}://#{r.host}#{":#{port}" unless DEFAULT_PORTS[scheme] == port}" end
def path(obj, *args, &block)
had its class previously registered with the application. If the app's
Return a path based on the class of the object. The object passed must have
def path(obj, *args, &block) app = self.class opts = app.opts klass = opts[:path_class_by_name] ? obj.class.name : obj.class unless meth = opts[:path_class_methods][klass] raise RodaError, "unrecognized object given to Roda#path: #{obj.inspect}" end path = send(meth, obj, *args, &block) path = request.script_name.to_s + path if opts[:add_script_name] path end
def url(*args, &block)
def url(*args, &block) "#{_base_url}#{path(*args, &block)}" end