module Pragma::Contract::Coercion::ClassMethods
Public Instance Methods
build_type(namespace, type)
click to toggle source
# File lib/pragma/contract/coercion.rb, line 41 def build_type(namespace, type) Object.const_get "Pragma::Contract::Types::#{namespace}::#{type.to_s.capitalize}" end
coercible(type)
click to toggle source
# File lib/pragma/contract/coercion.rb, line 15 def coercible(type) build_type 'Coercible', type end
form(type)
click to toggle source
# File lib/pragma/contract/coercion.rb, line 19 def form(type) # Dry::Types 0.13 renames Types::Form to Types::Params and the Int type to Integer. if Dry::Types['form.int'] build_type 'Form', type else build_type 'Params', type.to_sym == :int ? :integer : type end end
json(type)
click to toggle source
# File lib/pragma/contract/coercion.rb, line 29 def json(type) build_type 'Json', type end
maybe_coercible(type)
click to toggle source
# File lib/pragma/contract/coercion.rb, line 37 def maybe_coercible(type) build_type 'Maybe::Coercible', type end
maybe_strict(type)
click to toggle source
# File lib/pragma/contract/coercion.rb, line 33 def maybe_strict(type) build_type 'Maybe::Strict', type end
strict(type)
click to toggle source
# File lib/pragma/contract/coercion.rb, line 11 def strict(type) build_type 'Strict', type end