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 226 def path(obj, *args, &block) 227 app = self.class 228 klass = app.path_class_by_name? ? obj.class.name : obj.class 229 unless meth = app.path_class_methods[klass] 230 raise RodaError, "unrecognized object given to Roda#path: #{obj.inspect}" 231 end 232 233 path = send(meth, obj, *args, &block) 234 path = request.script_name.to_s + path if app.add_script_name? 235 path 236 end
url(*args, &block)
Similar to path, but returns a complete URL.
[show source]
# File lib/roda/plugins/path.rb 239 def url(*args, &block) 240 "#{_base_url}#{path(*args, &block)}" 241 end