Class: Coercer

Inherits:
Object
  • Object
show all
Defined in:
lib/brine/coercer.rb

Overview

coercer.rb

Instance Method Summary collapse

Constructor Details

#initializeCoercer

Returns a new instance of Coercer.



4
5
6
7
# File 'lib/brine/coercer.rb', line 4

def initialize
  @map = Hash.new(->(l, r){[l, r]})
  @map[[String, Time]] = ->(l, r){[Time.parse(l), r]}
end

Instance Method Details

#coerce(l, r) ⇒ Object



9
10
11
# File 'lib/brine/coercer.rb', line 9

def coerce(l, r)
  @map[[l.class, r.class]].call(l, r)
end