Sha256: dbe49d82ffecefc29d0595b554a4500d18b14796aa30262280ee14aca58d2400
Contents?: true
Size: 673 Bytes
Versions: 3
Compression:
Stored size: 673 Bytes
Contents
module Happy class Request < Rack::Request module DateParameterConverter class << self def convert!(params) params.each do |k, v| if looks_like_a_date?(v) params[k] = convert_to_date(v) elsif v.is_a? Hash convert!(v) end end end def looks_like_a_date?(v) v.is_a?(Hash) && v.has_key?('year') && v.has_key?('month') && v.has_key?('day') end def convert_to_date(v) DateTime.new(v['year'].to_i, v['month'].to_i, v['day'].to_i, v['hour'].to_i, v['minute'].to_i, v['second'].to_i) end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
happy-0.1.0 | lib/happy/request/date_parameter_converter.rb |
happy-0.1.0.pre28 | lib/happy/request/date_parameter_converter.rb |
happy-0.1.0.pre27 | lib/happy/request/date_parameter_converter.rb |