Class: ActionDispatch::Journey::Formatter::MissingRoute

Inherits:
Object
  • Object
show all
Defined in:
actionpack/lib/action_dispatch/journey/formatter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(constraints, missing_keys, unmatched_keys, routes, name) ⇒ MissingRoute

Returns a new instance of MissingRoute.



35
36
37
38
39
40
41
# File 'actionpack/lib/action_dispatch/journey/formatter.rb', line 35

def initialize(constraints, missing_keys, unmatched_keys, routes, name)
  @constraints = constraints
  @missing_keys = missing_keys
  @unmatched_keys = unmatched_keys
  @routes = routes
  @name = name
end

Instance Attribute Details

#constraintsObject (readonly)

Returns the value of attribute constraints



33
34
35
# File 'actionpack/lib/action_dispatch/journey/formatter.rb', line 33

def constraints
  @constraints
end

#missing_keysObject (readonly)

Returns the value of attribute missing_keys



33
34
35
# File 'actionpack/lib/action_dispatch/journey/formatter.rb', line 33

def missing_keys
  @missing_keys
end

#nameObject (readonly)

Returns the value of attribute name



33
34
35
# File 'actionpack/lib/action_dispatch/journey/formatter.rb', line 33

def name
  @name
end

#routesObject (readonly)

Returns the value of attribute routes



33
34
35
# File 'actionpack/lib/action_dispatch/journey/formatter.rb', line 33

def routes
  @routes
end

#unmatched_keysObject (readonly)

Returns the value of attribute unmatched_keys



33
34
35
# File 'actionpack/lib/action_dispatch/journey/formatter.rb', line 33

def unmatched_keys
  @unmatched_keys
end

Instance Method Details

#messageObject



51
52
53
54
55
56
# File 'actionpack/lib/action_dispatch/journey/formatter.rb', line 51

def message
  message = +"No route matches #{Hash[constraints.sort_by { |k, v| k.to_s }].inspect}"
  message << ", missing required keys: #{missing_keys.sort.inspect}" if missing_keys && !missing_keys.empty?
  message << ", possible unmatched constraints: #{unmatched_keys.sort.inspect}" if unmatched_keys && !unmatched_keys.empty?
  message
end

#paramsObject



47
48
49
# File 'actionpack/lib/action_dispatch/journey/formatter.rb', line 47

def params
  path("unknown")
end

#path(method_name) ⇒ Object



43
44
45
# File 'actionpack/lib/action_dispatch/journey/formatter.rb', line 43

def path(method_name)
  raise ActionController::UrlGenerationError.new(message, routes, name, method_name)
end