Sha256: dc88a82b656bcc4fb7a290224165e93573ecbf70e0ed14894847a8503cbdc3a8

Contents?: true

Size: 635 Bytes

Versions: 3

Compression:

Stored size: 635 Bytes

Contents

require 'happy/request/date_parameter_converter'

module Happy
  # Happy's own little request class. It extends {Rack::Request} with
  # a bit of convenience functionality.
  #
  class Request < Rack::Request
    # Override the default #params method so it returns a Hash with indifferent
    # access if ActiveSupport is available.
    def params
      @env['happy.params'] ||= if defined?(HashWithIndifferentAccess)
        super.with_indifferent_access
      else
        super
      end
    end

  protected

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
happy-0.1.0 lib/happy/request.rb
happy-0.1.0.pre28 lib/happy/request.rb
happy-0.1.0.pre27 lib/happy/request.rb