Module: Tito::Base::ParamNester
- Defined in:
- lib/tito/base.rb
Overview
Class Method Summary collapse
Class Method Details
.append_key(root_key, key) ⇒ Object
184 185 186 |
# File 'lib/tito/base.rb', line 184 def self.append_key(root_key, key) root_key.nil? ? :"#{key}" : :"#{root_key}[#{key.to_s}]" end |
.encode(value, key = nil, out_hash = {}) ⇒ Object
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/tito/base.rb', line 168 def self.encode(value, key = nil, out_hash = {}) case value when Hash value.each { |k,v| encode(v, append_key(key, k), out_hash) } out_hash when Array value.each { |v| encode(v, "#{key}[]", out_hash) } out_hash when nil '' else out_hash[key] = value out_hash end end |