Module: Roda::RodaPlugins::Path::InstanceMethods

Defined in:
lib/roda/plugins/path.rb

Instance Method Summary collapse

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.



178
179
180
181
182
183
184
185
186
187
# File 'lib/roda/plugins/path.rb', line 178

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