class Parameters::Param
Attributes
description[R]
Description of parameter
name[R]
Name of parameter
type[R]
Enforced type of the parameter
Public Class Methods
new(name,type=nil,description=nil)
click to toggle source
Creates a new Param
object.
@param [Symbol, String] name
The name of the parameter.
@param [Class, nil] type
The enforced type of the parameter.
@param [String, nil] description
The description of the parameter.
@api semipublic
# File lib/parameters/param.rb, line 29 def initialize(name,type=nil,description=nil) @name = name.to_sym @type = if (type.kind_of?(Types::Type)) || (type.kind_of?(Class) && (type < Types::Type)) type else Types[type] end @description = description end
Public Instance Methods
coerce(value)
click to toggle source
Coerces the value into the param type.
@param [Object] value
The value to coerce.
@return [Object]
The coerced value.
@api semipublic
# File lib/parameters/param.rb, line 52 def coerce(value) if (value.nil? || (@type === value)) value else @type.coerce(value) end end