class EvilEvents::Shared::TypeConverter::TypeBuilder
@api public @since 0.2.0
Attributes
type_atom[R]
@return [Concurrent::Atom<EvilEvents::Shared::Types::Any>]
@since 0.2.0
Public Class Methods
new()
click to toggle source
@api public @since 0.2.0
# File lib/evil_events/shared/type_converter/type_builder.rb, line 9 def initialize @type_atom = Concurrent::Atom.new(EvilEvents::Shared::Types::Any) end
Public Instance Methods
append(option, value)
click to toggle source
@param option [Symbol] @param value [Mixed] @return self
@api public @since 0.2.0
# File lib/evil_events/shared/type_converter/type_builder.rb, line 19 def append(option, value) type_atom.swap do |type| case option when :default # NOTE: Dry::Types callable wrapper (see Dry::Types::Default::Callable#evaulate) default_value = value.is_a?(Proc) ? (->(_type) { value.call }) : (proc { value }) type.default(default_value) when :constructor type.constructor(value) else type end end self end
result()
click to toggle source
@return [EvilEvents::Shared::Types::Any]
@api public @since 0.2.0
# File lib/evil_events/shared/type_converter/type_builder.rb, line 40 def result type_atom.value end