module Extant::Coercers
Public Class Methods
find(type)
click to toggle source
# File lib/extant/coercers.rb, line 3 def self.find(type) if type.is_a?(::Hash) coercer_options = { hash_format: type } type = HashCoercerBuilder.build(coercer_options) end if type.is_a?(::Array) coercer_options = { array_format: type } type = ArrayCoercerBuilder.build(coercer_options) end if type.is_a?(Class) && type.ancestors.include?(Extant::Coercers::Base) coercer_class = type else coercer_class = Object.const_get("Extant::Coercers::#{type}") unless coercer_class.method_defined?(:coerce) raise "#{type} must respond to #coerce" end end coercer_class end