Class: KubeSchema::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/kube_schema/resource.rb

Class Method Summary collapse

Instance Method Summary collapse

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

.schemaObject

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_hObject



21
22
23
# File 'lib/kube_schema/resource.rb', line 21

def to_h
  @data.to_h
end