Class: KubeSchema::Resource
- Inherits:
-
Object
- Object
- KubeSchema::Resource
- Defined in:
- lib/kube_schema/resource.rb
Class Method Summary collapse
-
.schema ⇒ Object
Gets overridden by the factory in KubeSchema::Instance.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(hash = nil, &block) ⇒ Resource
constructor
Subclasses generated by Instance#[] have a class-level .schema.
- #to_h ⇒ Object
Constructor Details
#initialize(hash = nil, &block) ⇒ Resource
Subclasses generated by Instance#[] have a class-level .schema. When called directly via KubeSchema.parse(hash), the hash is passed in.
11 12 13 14 |
# File 'lib/kube_schema/resource.rb', line 11 def initialize(hash = nil, &block) @data = BlackHoleStruct.new(hash) @data.instance_exec(&block) if block end |
Class Method Details
.schema ⇒ Object
Gets overridden by the factory in KubeSchema::Instance
17 18 19 |
# File 'lib/kube_schema/resource.rb', line 17 def self.schema nil end |
Instance Method Details
#==(other) ⇒ Object
25 26 27 |
# File 'lib/kube_schema/resource.rb', line 25 def ==(other) other.is_a?(Resource) && to_h == other.to_h end |
#to_h ⇒ Object
21 22 23 |
# File 'lib/kube_schema/resource.rb', line 21 def to_h @data.to_h end |