Public Instance methods
path(obj, *args, &block)
Return a path based on the class of the object. The object passed must have had its class previously registered with the application. If the app’s :add_script_name option is true, this prepends the SCRIPT_NAME to the path.
[show source]
# File lib/roda/plugins/path.rb 223 def path(obj, *args, &block) 224 app = self.class 225 opts = app.opts 226 klass = opts[:path_class_by_name] ? obj.class.name : obj.class 227 unless meth = opts[:path_class_methods][klass] 228 raise RodaError, "unrecognized object given to Roda#path: #{obj.inspect}" 229 end 230 231 path = send(meth, obj, *args, &block) 232 path = request.script_name.to_s + path if opts[:add_script_name] 233 path 234 end
url(*args, &block)
Similar to path
, but returns a complete URL.
[show source]
# File lib/roda/plugins/path.rb 237 def url(*args, &block) 238 "#{_base_url}#{path(*args, &block)}" 239 end