Class: Coercer
- Inherits:
-
Object
- Object
- Coercer
- Defined in:
- lib/brine/coercer.rb
Overview
- coercer.rb
Instance Method Summary collapse
- #coerce(l, r) ⇒ Object
-
#initialize ⇒ Coercer
constructor
A new instance of Coercer.
Constructor Details
#initialize ⇒ Coercer
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 |