Class: TypeGeneric
- Inherits:
-
Object
- Object
- TypeGeneric
- Defined in:
- lib/ansible/ruby/models/type_generic.rb
Overview
See LICENSE.txt for license
Instance Attribute Summary collapse
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean
- #error(attribute, value) ⇒ Object
- #hash ⇒ Object
-
#initialize(klass) ⇒ TypeGeneric
constructor
A new instance of TypeGeneric.
- #valid?(value) ⇒ Boolean
Constructor Details
#initialize(klass) ⇒ TypeGeneric
Returns a new instance of TypeGeneric.
5 6 7 |
# File 'lib/ansible/ruby/models/type_generic.rb', line 5 def initialize(klass) @klass = klass end |
Instance Attribute Details
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
3 4 5 |
# File 'lib/ansible/ruby/models/type_generic.rb', line 3 def klass @klass end |
Instance Method Details
#eql?(other) ⇒ Boolean
21 22 23 |
# File 'lib/ansible/ruby/models/type_generic.rb', line 21 def eql?(other) other.is_a?(TypeGeneric) && other.klass == @klass end |
#error(attribute, value) ⇒ Object
16 17 18 19 |
# File 'lib/ansible/ruby/models/type_generic.rb', line 16 def error(attribute, value) object = validation_object(value) "Attribute #{attribute} expected to be a #{@klass} but was a #{object.class}" end |
#hash ⇒ Object
25 26 27 |
# File 'lib/ansible/ruby/models/type_generic.rb', line 25 def hash @klass.hash end |
#valid?(value) ⇒ Boolean
9 10 11 12 13 14 |
# File 'lib/ansible/ruby/models/type_generic.rb', line 9 def valid?(value) validation_object = validation_object(value) # Don't worry about nil return true unless validation_object validation_object.is_a? @klass end |