Module: Xqsr3::Quality::ParameterChecking
- Defined in:
- lib/xqsr3/quality/parameter_checking.rb
Overview
Inclusion module that creates class and instance methods check_parameter that may be used to check 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_parameterinstead. -
.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_optionoption (with the valuetrue) is merged in before calling check_parameter()
-
-
Options:
214 215 216 217 |
# File 'lib/xqsr3/quality/parameter_checking.rb', line 214 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
198 199 200 201 |
# File 'lib/xqsr3/quality/parameter_checking.rb', line 198 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:
-
valuethe parameter whose value and type is to be checked -
namethe name of the parameter to be checked -
optionsoptions
-
-
Options:
-
:allow_nil(boolean) Thevaluemust not benilunless this option is true -
:nilan alias for:allow_nil -
:ignore_case(boolean) When:valuesis 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 whichvaluemust be (or must be derived from). One of these types may be an array of types, in which casevaluemay be an array that must consist wholly of those types -
:type(::Class) A single type parameter, used only if:typesis not specified -
:values(::Array) an array of values one of whichvaluemust 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 anilreturn 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
-
189 190 191 192 |
# File 'lib/xqsr3/quality/parameter_checking.rb', line 189 def self.check_parameter value, name, = {}, &block Util_.check_parameter value, name, , &block end |
.included(base) ⇒ Object
:nodoc:
104 105 106 107 |
# File 'lib/xqsr3/quality/parameter_checking.rb', line 104 def self.included base # :nodoc: base.extend self end |