Class: Kangaru::Request

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Configurable
Defined in:
lib/kangaru/request.rb

Constant Summary collapse

DEFAULT_CONTROLLER =
"DefaultController".freeze
DEFAULT_ACTION =
:default

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Configurable

#config

Methods included from Concern

#append_features, #class_methods, #included

Constructor Details

#initialize(path:, params:) ⇒ Request

Returns a new instance of Request.



15
16
17
18
# File 'lib/kangaru/request.rb', line 15

def initialize(path:, params:)
  @path = path
  @params = params
end

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params.



13
14
15
# File 'lib/kangaru/request.rb', line 13

def params
  @params
end

#pathObject (readonly)

Returns the value of attribute path.



13
14
15
# File 'lib/kangaru/request.rb', line 13

def path
  @path
end

Instance Method Details

#actionObject



26
27
28
# File 'lib/kangaru/request.rb', line 26

def action
  path_parser.action || DEFAULT_ACTION
end

#controllerObject



20
21
22
23
24
# File 'lib/kangaru/request.rb', line 20

def controller
  return default_controller if path_parser.controller.nil?

  path_parser.controller&.to_class_name(suffix: Controller::SUFFIX) || raise
end