Class: ParamGuard::ParamDefinition
- Inherits:
-
Struct
- Object
- Struct
- ParamGuard::ParamDefinition
- Defined in:
- lib/param_guard/param_definition.rb
Overview
Rules describing the requirements for a parameter.
Instance Attribute Summary collapse
-
#presence ⇒ Object
Returns the value of attribute presence.
-
#subdef ⇒ Object
Returns the value of attribute subdef.
-
#type_or_types ⇒ Object
Returns the value of attribute type_or_types.
Instance Method Summary collapse
Instance Attribute Details
#presence ⇒ Object
Returns the value of attribute presence
4 5 6 |
# File 'lib/param_guard/param_definition.rb', line 4 def presence @presence end |
#subdef ⇒ Object
Returns the value of attribute subdef
4 5 6 |
# File 'lib/param_guard/param_definition.rb', line 4 def subdef @subdef end |
#type_or_types ⇒ Object
Returns the value of attribute type_or_types
4 5 6 |
# File 'lib/param_guard/param_definition.rb', line 4 def type_or_types @type_or_types end |
Instance Method Details
#required? ⇒ Boolean
5 6 7 |
# File 'lib/param_guard/param_definition.rb', line 5 def required? presence == :required end |
#types ⇒ Object
9 10 11 |
# File 'lib/param_guard/param_definition.rb', line 9 def types Array(type_or_types) end |
#types_for_sentence ⇒ Object
13 14 15 16 17 |
# File 'lib/param_guard/param_definition.rb', line 13 def types_for_sentence a = types.map(&:to_s) return nil if a.empty? [a[0..-3] + [a.last(2).join(' or ')]].compact.join(', ') end |