Module: ClassX::AttributeMethods::ClassMethods::CoerceWithHash
- Defined in:
- lib/classx/attribute.rb
Overview
:nodoc:
Instance Method Summary collapse
Instance Method Details
#coerce(val) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/classx/attribute.rb', line 28 def coerce val result = val config[:coerce].each do |cond, rule| case cond when Proc if cond.call(val) result = rule.call(val) break end when Symbol if val.respond_to? cond result = rule.call(val) break end when Module if val.kind_of? cond result = rule.call(val) break end end end return result end |