lib/sinclair/caster.rb in sinclair-1.16.1 vs lib/sinclair/caster.rb in sinclair-1.16.2

- old
+ new

@@ -315,11 +315,11 @@ # # @return [Caster] # @param block [Proc] Proc to be used when converting the value object def initialize(&block) - @block = block.to_proc + @block = block&.to_proc end # Cast a value using the given the set +block+ # # @param value [Object] value to be converted @@ -346,9 +346,11 @@ # caster.cast(100) # returns 2 # caster.cast(8, base: 2) # returns 3 # # @return [Object] the result of the converting block def cast(value, **opts) + return value unless block + options = opts.select do |key, _| options_keys.include?(key) end block.call(value, **options)