Exception: Flame::Errors::RouteExtraArgumentsError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/flame/errors/route_extra_arguments_error.rb

Overview

Error for Route initialization

Instance Method Summary collapse

Constructor Details

#initialize(ctrl, action, path, extra) ⇒ RouteExtraArgumentsError

Create a new instance of error

Parameters:

Options Hash (extra):

  • :type (Symbol)

    required or optional

  • :place (Symbol)

    extra arguments in controller or path

  • :args (Array<Symbol>)

    extra arguments



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/flame/errors/route_extra_arguments_error.rb', line 15

def initialize(ctrl, action, path, extra)
  extra[:type_name] = { req: 'required', opt: 'optional' }[extra[:type]]

  entity = {
    ## Error if path has no arguments, that controller's method has
    ## NOTE: It isn't using because `Flame::Path#adopt`
    ctrl: "Path '#{path}'",
    ## Error if path has more arguments, than controller's method
    path: "Action '#{ctrl}##{action}'"
  }[extra[:place]]

  super("#{entity} has no #{extra[:type_name]} arguments #{extra[:args].inspect}")
end