Class: Shaf::Authenticator::Parameter
- Inherits:
-
Object
- Object
- Shaf::Authenticator::Parameter
- Defined in:
- lib/shaf/authenticator/parameter.rb
Instance Attribute Summary collapse
-
#default ⇒ Object
readonly
Returns the value of attribute default.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Instance Method Summary collapse
-
#initialize(name, required: true, default: nil, values: nil) ⇒ Parameter
constructor
A new instance of Parameter.
- #optional? ⇒ Boolean
- #required? ⇒ Boolean
- #valid?(value) ⇒ Boolean
Constructor Details
#initialize(name, required: true, default: nil, values: nil) ⇒ Parameter
Returns a new instance of Parameter.
8 9 10 11 12 13 |
# File 'lib/shaf/authenticator/parameter.rb', line 8 def initialize(name, required: true, default: nil, values: nil) @name = name @required = required @default = default @values = values&.map(&:downcase) end |
Instance Attribute Details
#default ⇒ Object (readonly)
Returns the value of attribute default.
6 7 8 |
# File 'lib/shaf/authenticator/parameter.rb', line 6 def default @default end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/shaf/authenticator/parameter.rb', line 6 def name @name end |
#values ⇒ Object (readonly)
Returns the value of attribute values.
6 7 8 |
# File 'lib/shaf/authenticator/parameter.rb', line 6 def values @values end |
Instance Method Details
#optional? ⇒ Boolean
19 20 21 |
# File 'lib/shaf/authenticator/parameter.rb', line 19 def optional? !required? end |
#required? ⇒ Boolean
15 16 17 |
# File 'lib/shaf/authenticator/parameter.rb', line 15 def required? @required end |
#valid?(value) ⇒ Boolean
23 24 25 26 27 28 |
# File 'lib/shaf/authenticator/parameter.rb', line 23 def valid?(value) return optional? if value.nil? return true unless values values.include?(value.downcase) end |