Class: Tengine::Resource::Credential::AuthField
- Inherits:
-
Object
- Object
- Tengine::Resource::Credential::AuthField
- Defined in:
- lib/tengine/resource/credential.rb
Instance Attribute Summary collapse
-
#default ⇒ Object
readonly
Returns the value of attribute default.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#optional ⇒ Object
readonly
Returns the value of attribute optional.
-
#type_key ⇒ Object
readonly
Returns the value of attribute type_key.
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(name, type_key, options = {}) ⇒ AuthField
constructor
A new instance of AuthField.
- #optional? ⇒ Boolean
- #to_s ⇒ Object
- #validate(credential, hash) ⇒ Object
Constructor Details
#initialize(name, type_key, options = {}) ⇒ AuthField
Returns a new instance of AuthField.
57 58 59 60 61 62 |
# File 'lib/tengine/resource/credential.rb', line 57 def initialize(name, type_key, = {}) @name, @type_key = name.to_s, type_key.to_sym @options = || {} @optional = !!@options[:optional] @default = @options[:default] end |
Instance Attribute Details
#default ⇒ Object (readonly)
Returns the value of attribute default.
56 57 58 |
# File 'lib/tengine/resource/credential.rb', line 56 def default @default end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
56 57 58 |
# File 'lib/tengine/resource/credential.rb', line 56 def name @name end |
#optional ⇒ Object (readonly)
Returns the value of attribute optional.
56 57 58 |
# File 'lib/tengine/resource/credential.rb', line 56 def optional @optional end |
#type_key ⇒ Object (readonly)
Returns the value of attribute type_key.
56 57 58 |
# File 'lib/tengine/resource/credential.rb', line 56 def type_key @type_key end |
Instance Method Details
#eql?(other) ⇒ Boolean
72 73 74 |
# File 'lib/tengine/resource/credential.rb', line 72 def eql?(other) self.name <=> other.to_s end |
#hash ⇒ Object
75 76 77 |
# File 'lib/tengine/resource/credential.rb', line 75 def hash self.name.hash end |
#optional? ⇒ Boolean
68 69 70 |
# File 'lib/tengine/resource/credential.rb', line 68 def optional? @optional end |
#to_s ⇒ Object
78 79 80 |
# File 'lib/tengine/resource/credential.rb', line 78 def to_s self.name end |
#validate(credential, hash) ⇒ Object
63 64 65 66 67 |
# File 'lib/tengine/resource/credential.rb', line 63 def validate(credential, hash) unless optional credential.errors.add(:auth_values, "#{name.inspect} can't be blank") if hash[name].blank? end end |