module Card::Path::CastParams
normalizes certain path opts to specified data types
Private Instance Methods
cast_each_path_hash(hash, cast_hash)
click to toggle source
# File lib/card/path/cast_params.rb, line 17 def cast_each_path_hash hash, cast_hash hash.each do |key, value| next unless (cast_to = cast_hash[key]) hash[key] = cast_path_value value, cast_to end end
cast_path_hash(hash, cast_hash=nil)
click to toggle source
# File lib/card/path/cast_params.rb, line 10 def cast_path_hash hash, cast_hash=nil return hash unless hash.is_a? Hash cast_each_path_hash hash, (cast_hash || self.class.cast_params) hash end
cast_path_value(value, cast_to)
click to toggle source
# File lib/card/path/cast_params.rb, line 25 def cast_path_value value, cast_to if cast_to.is_a? Hash cast_path_hash value, cast_to else send "cast_path_value_as_#{cast_to}", value end end
cast_path_value_as_array(value)
click to toggle source
# File lib/card/path/cast_params.rb, line 33 def cast_path_value_as_array value Array.wrap value end