Class: WelltreatStoreFramework::Controller::Request

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = { }) ⇒ Request

Returns a new instance of Request.



33
34
35
36
37
38
39
40
41
# File 'lib/welltreat_store_framework/controller.rb', line 33

def initialize(attrs = { })
  @headers      = { }
  @params       = { }
  @path         = nil
  @rack_request = nil
  attrs.each do |k, v|
    self.send(:"#{k.to_s}=", v)
  end
end

Instance Attribute Details

#envObject

Returns the value of attribute env.



31
32
33
# File 'lib/welltreat_store_framework/controller.rb', line 31

def env
  @env
end

#headersObject

Returns the value of attribute headers.



31
32
33
# File 'lib/welltreat_store_framework/controller.rb', line 31

def headers
  @headers
end

#paramsObject

Returns the value of attribute params.



31
32
33
# File 'lib/welltreat_store_framework/controller.rb', line 31

def params
  @params
end

#pathObject

Returns the value of attribute path.



31
32
33
# File 'lib/welltreat_store_framework/controller.rb', line 31

def path
  @path
end

#rack_requestObject

Returns the value of attribute rack_request.



31
32
33
# File 'lib/welltreat_store_framework/controller.rb', line 31

def rack_request
  @rack_request
end

Class Method Details

.initialize_from_env(env) ⇒ Object



52
53
54
55
56
57
58
59
60
61
# File 'lib/welltreat_store_framework/controller.rb', line 52

def initialize_from_env(env)
  request = Rack::Request.new(env)
  self.new(
      :params       => request.params,
      :headers      => env,
      :rack_request => request,
      :path         => request.path,
      :env          => env
  )
end

Instance Method Details

#[](k) ⇒ Object



47
48
49
# File 'lib/welltreat_store_framework/controller.rb', line 47

def [](k)
  self.params[k]
end

#get_header(k) ⇒ Object



43
44
45
# File 'lib/welltreat_store_framework/controller.rb', line 43

def get_header(k)
  self.headers[k]
end