Class: Primalize::Single::Primalizer
- Inherits:
-
Object
- Object
- Primalize::Single::Primalizer
- Includes:
- Type
- Defined in:
- lib/primalize/single.rb
Constant Summary
Constants included from Type
Instance Method Summary collapse
- #===(value) ⇒ Object
-
#initialize(primalizer, &coercion) ⇒ Primalizer
constructor
A new instance of Primalizer.
- #inspect ⇒ Object
Methods included from Type
Constructor Details
#initialize(primalizer, &coercion) ⇒ Primalizer
Returns a new instance of Primalizer.
344 345 346 347 348 349 350 351 352 353 354 355 |
# File 'lib/primalize/single.rb', line 344 def initialize primalizer, &coercion @primalizer = primalizer @coercion = proc do |obj| # FIXME: this is dumb begin coerced = (coercion || DEFAULT_COERCION).call(obj) primalizer.new(coerced).call rescue ArgumentError => e raise TypeError.new(e) end end end |