class Dry::Data::Type
Attributes
constructor[R]
options[R]
primitive[R]
Public Class Methods
[](primitive)
click to toggle source
# File lib/dry/data/type.rb, line 17 def self.[](primitive) if primitive == ::Array Type::Array elsif primitive == ::Hash Type::Hash else Type end end
constructor(input)
click to toggle source
# File lib/dry/data/type.rb, line 27 def self.constructor(input) input end
new(constructor, options = {})
click to toggle source
# File lib/dry/data/type.rb, line 31 def initialize(constructor, options = {}) @constructor = constructor @options = options @primitive = options.fetch(:primitive) end
Public Instance Methods
call(input)
click to toggle source
# File lib/dry/data/type.rb, line 41 def call(input) constructor[input] end
Also aliased as: []
name()
click to toggle source
# File lib/dry/data/type.rb, line 37 def name primitive.name end
try(input)
click to toggle source
# File lib/dry/data/type.rb, line 46 def try(input) call(input) end
valid?(input)
click to toggle source
# File lib/dry/data/type.rb, line 50 def valid?(input) input.is_a?(primitive) end