Class: Happy::Request

Inherits:
Rack::Request
  • Object
show all
Defined in:
lib/happy/request.rb,
lib/happy/request/date_parameter_converter.rb

Overview

Happy's own little request class. It extends Rack::Request with a bit of convenience functionality.

Defined Under Namespace

Modules: DateParameterConverter

Instance Method Summary collapse

Instance Method Details

#paramsObject

Override the default #params method so it returns a Hash with indifferent access if ActiveSupport is available.


10
11
12
13
14
15
16
# File 'lib/happy/request.rb', line 10

def params
  @env['happy.params'] ||= if defined?(HashWithIndifferentAccess)
    super.with_indifferent_access
  else
    super
  end
end

#parse_query(qs) ⇒ Object (protected)


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

def parse_query(qs)
  super(qs).tap do |p|
    DateParameterConverter.convert!(p)
  end
end