Module: Roda::RodaPlugins::Path::InstanceMethods
- Defined in:
- lib/roda/plugins/path.rb
Instance Method Summary collapse
-
#path(obj, *args) ⇒ Object
Return a path based on the class of the object.
Instance Method Details
#path(obj, *args) ⇒ Object
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.
173 174 175 176 177 178 179 180 181 182 |
# File 'lib/roda/plugins/path.rb', line 173 def path(obj, *args) app = self.class unless blk = app.path_block(obj.class) raise RodaError, "unrecognized object given to Roda#path: #{obj.inspect}" end path = instance_exec(obj, *args, &blk) path = request.script_name.to_s + path if app.opts[:add_script_name] path end |