Module: Hashie::Extensions::Coercion

Defined in:
lib/hashie/extensions/coercion.rb

Defined Under Namespace

Modules: ClassMethods, InstanceMethods

Constant Summary collapse

CORE_TYPES =
{
  Integer    => :to_i,
  Float      => :to_f,
  Complex    => :to_c,
  Rational   => :to_r,
  String     => :to_s,
  Symbol     => :to_sym
}.freeze
ABSTRACT_CORE_TYPES =
{ Numeric => [Integer, Float, Complex, Rational] }

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object


22
23
24
25
26
27
28
29
# File 'lib/hashie/extensions/coercion.rb', line 22

def self.included(base)
  base.send :include, InstanceMethods
  base.extend ClassMethods
  unless base.method_defined?(:set_value_without_coercion)
    base.send :alias_method, :set_value_without_coercion, :[]=
  end
  base.send :alias_method, :[]=, :set_value_with_coercion
end