Sha256: 5b8f518efac5b5ad3d24fcc0192eef1e859e89f96ffef25abf90b1cc38ce87ec
Contents?: true
Size: 784 Bytes
Versions: 4
Compression:
Stored size: 784 Bytes
Contents
module Acfs::ParameterDecoder module Functions def self.deep_decode(hash) return hash unless hash.is_a? Hash hash.each_pair do |key, value| if value.is_a? Hash deep_decode(value) hash[key] = decode_typhoeus_array(value) end end end def self.decode_typhoeus_array(hash) if typhoeus_encoded? hash hash.inject([]) do |memo, (key, val)| memo[Integer(key)] = val memo end else hash end end def self.typhoeus_encoded?(hash) return false if hash.empty? self.keys.sort == (0...hash.keys.size).map { |i| i.to_s } end end def self.included(base) base.send :before_filter do Functions.deep_decode params end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
acfs-0.37.0 | lib/acfs/parameter_decoder.rb |
acfs-0.36.0 | lib/acfs/parameter_decoder.rb |
acfs-0.34.1 | lib/acfs/parameter_decoder.rb |
acfs-0.34.0 | lib/acfs/parameter_decoder.rb |