Module: Xqsr3::Quality::ParameterChecking
- Defined in:
- lib/xqsr3/quality/parameter_checking.rb
Overview
Inclusion module that creates class and instance methods check_option() and check_parameter() that may be used to check option/parameter values and types.
Class Method Summary collapse
-
.check_option(h, name, options = {}, &block) ⇒ Object
Specific form of the check_parameter() that is used to check options, taking instead the hash and the key.
-
.check_param(value, name, options = {}, &block) ⇒ Object
Please use
check_parameter
instead. -
.check_parameter(value, name, options = {}, &block) ⇒ Object
Check a given parameter (value=
value
, name=name
) for type and value. -
.included(base) ⇒ Object
:nodoc:.
Class Method Details
.check_option(h, name, options = {}, &block) ⇒ Object
Specific form of the check_parameter() that is used to check options, taking instead the hash and the key
Signature
-
Parameters:
-
h
(::Hash) The options hash from which the named element is to be tested. May not benil
-
name
(::String, ::Symbol, [ ::String, ::Symbol ]) The options key name, or an array of names. May not benil
-
options
(::Hash) options that moderate the behaviour in the same way as for check_parameter() except that the:treat_as_option
option (with the valuetrue
) is merged in before calling check_parameter()
-
-
Options:
215 216 217 218 |
# File 'lib/xqsr3/quality/parameter_checking.rb', line 215 def self.check_option h, name, = {}, &block Util_.check_option h, name, , &block end |
.check_param(value, name, options = {}, &block) ⇒ Object
This is obsolete, and will be removed in a future version.
Please use check_parameter
instead
199 200 201 202 |
# File 'lib/xqsr3/quality/parameter_checking.rb', line 199 def self.check_param value, name, = {}, &block Util_.check_parameter value, name, , &block end |
.check_parameter(value, name, options = {}, &block) ⇒ Object
Check a given parameter (value=value
, name=name
) for type and value
Signature
-
Parameters:
-
value
the parameter whose value and type is to be checked -
name
the name of the parameter to be checked -
options
options
-
-
Options:
-
:allow_nil
(boolean) Thevalue
must not benil
unless this option is true -
:nil
an alias for:allow_nil
-
:ignore_case
(boolean) When:values
is specified, comparisons of strings, or arrays of strings, will be carried out in a case-insensitive manner -
:types
(::Array) An array of types one of whichvalue
must be (or must be derived from). One of these types may be an array of types, in which casevalue
may be an array that must consist wholly of those types -
:type
(::Class) A single type parameter, used only if:types
is not specified -
:values
(::Array) an array of values one of whichvalue
must be -
:responds_to
(::Array) An array of symbols specifying all messages to which the parameter will respond -
:reject_empty
(boolean) requires value to respond toempty?
message and to do so with false, unlessnil
-
:require_empty
(boolean) requires value to respond toempty?
message and to do so with true, unlessnil
-
:nothrow
(boolean) causes failure to be indicated by anil
return rather than a thrown exception -
:message
(boolean) specifies a message to be used in any thrown exception, which suppresses internal message preparation -
:treat_as_option
(boolean) If true, the value will be treated as an option when reporting check failure
-
190 191 192 193 |
# File 'lib/xqsr3/quality/parameter_checking.rb', line 190 def self.check_parameter value, name, = {}, &block Util_.check_parameter value, name, , &block end |
.included(base) ⇒ Object
:nodoc:
105 106 107 108 |
# File 'lib/xqsr3/quality/parameter_checking.rb', line 105 def self.included base # :nodoc: base.extend self end |