Class: RailsParam::Coercion::HashParam

Inherits:
VirtualParam show all
Defined in:
lib/rails_param/coercion/hash_param.rb

Instance Attribute Summary

Attributes inherited from VirtualParam

#options, #param, #type

Instance Method Summary collapse

Methods inherited from VirtualParam

#initialize

Constructor Details

This class inherits a constructor from RailsParam::Coercion::VirtualParam

Instance Method Details

#coerceObject

Raises:

  • (ArgumentError)


4
5
6
7
8
9
# File 'lib/rails_param/coercion/hash_param.rb', line 4

def coerce
  return param if param.is_a?(ActionController::Parameters)
  raise ArgumentError unless param.respond_to?(:split)

  Hash[param.split(options[:delimiter] || ",").map { |c| c.split(options[:separator] || ":") }]
end