class TLAW::Param::Type

@private

Attributes

type[R]

Public Class Methods

new(type) click to toggle source
# File lib/tlaw/param/type.rb, line 24
def initialize(type)
  @type = type
end
parse(options) click to toggle source
# File lib/tlaw/param/type.rb, line 7
def self.parse(options)
  type = options[:type]

  case type
  when nil
    options[:enum] ? EnumType.new(options[:enum]) : Type.new(nil)
  when Class
    ClassType.new(type)
  when Symbol
    DuckType.new(type)
  when Hash
    EnumType.new(type)
  else
    fail ArgumenError, "Undefined type #{type}"
  end
end

Public Instance Methods

_convert(value) click to toggle source
# File lib/tlaw/param/type.rb, line 40
def _convert(value)
  value
end
convert(value) click to toggle source
# File lib/tlaw/param/type.rb, line 32
def convert(value)
  validate(value) && _convert(value)
end
nonconvertible!(value, reason) click to toggle source
# File lib/tlaw/param/type.rb, line 44
def nonconvertible!(value, reason)
  fail Nonconvertible,
       "#{self} can't convert  #{value.inspect}: #{reason}"
end
to_doc_type() click to toggle source
# File lib/tlaw/param/type.rb, line 28
def to_doc_type
  nil
end
validate(_value) click to toggle source
# File lib/tlaw/param/type.rb, line 36
def validate(_value)
  true
end