Class: SanaController::Params

Inherits:
Object
  • Object
show all
Defined in:
lib/sana_controller.rb

Overview

named access to request headers

Instance Method Summary collapse

Constructor Details

#initialize(request, mapping = {}) ⇒ Params

constructor

Examples:

mapping

params = SanaController::Params.new(request, {shell_name: 0, halted: 6, halted_ghost_name: 7}) # mapping for Reference0, 6 and 7

73
74
75
76
# File 'lib/sana_controller.rb', line 73

def initialize(request, mapping = {})
  @request = request
  @mapping = mapping
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method) ⇒ String

named access to the header

Examples:

named access

params.shell_name == params.Reference0

83
84
85
# File 'lib/sana_controller.rb', line 83

def method_missing(method)
  @request[method] || @request["Reference#{@mapping[method]}".to_sym]
end