Sha256: 71f0419f3cfada33fc0e329d4dbe6f6a64bccd1e91a3ad01d46fb64875a4dd0d
Contents?: true
Size: 698 Bytes
Versions: 2
Compression:
Stored size: 698 Bytes
Contents
require 'much-plugin' module Dk module HasSetParam include MuchPlugin plugin_included do include InstanceMethods end module InstanceMethods def set_param(key, value) self.params.merge!(dk_normalize_params(key => value)) end private def dk_normalize_params(params) StringifyParams.new(params || {}) end end module StringifyParams def self.new(object) case(object) when ::Hash object.inject({}){ |h, (k, v)| h.merge(k.to_s => self.new(v)) } when ::Array object.map{ |item| self.new(item) } else object end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dk-0.1.1 | lib/dk/has_set_param.rb |
dk-0.1.0 | lib/dk/has_set_param.rb |