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

Returns a new instance of RouteExtraArgumentsError.



7
8
9
10
11
12
13
14
15
16
# File 'lib/flame/errors/route_extra_arguments_error.rb', line 7

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

Instance Method Details

#messageObject



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/flame/errors/route_extra_arguments_error.rb', line 18

def message
  case @extra[:place]
  when :ctrl
    ## Error if path has no arguments, that controller's method has
    ## NOTE: It isn't using because `Flame::Path#adopt`
    "Path '#{@path}' has no #{@extra[:type_name]}" \
      " arguments #{@extra[:args].inspect}"
  when :path
    ## Error if path has more arguments, than controller's method
    "Action '#{@ctrl}##{@action}' has no #{@extra[:type_name]}" \
      " arguments #{@extra[:args].inspect}"
  end
end