Module: Kube::Cluster::Resource::DirtyTracking
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/kube/cluster/resource/dirty_tracking.rb', line 42
def method_missing(name, *args, &block)
if name.end_with?("_changed?")
attr = name.to_s.delete_suffix("_changed?").to_sym
old_val = @clean[attr]
new_val = to_h[attr]
old_val != new_val
else
super
end
end
|
Instance Method Details
#changed ⇒ Object
16
17
18
|
# File 'lib/kube/cluster/resource/dirty_tracking.rb', line 16
def changed
diff_keys(to_h, @clean)
end
|
#changed? ⇒ Boolean
12
13
14
|
# File 'lib/kube/cluster/resource/dirty_tracking.rb', line 12
def changed?
to_h != @clean
end
|
#changes ⇒ Object
20
21
22
|
# File 'lib/kube/cluster/resource/dirty_tracking.rb', line 20
def changes
build_changes(to_h, @clean)
end
|
#changes_applied ⇒ Object
24
25
26
|
# File 'lib/kube/cluster/resource/dirty_tracking.rb', line 24
def changes_applied
snapshot!
end
|
#patch_data ⇒ Object
Data suitable for a strategic-merge patch: only the keys/sub-trees that differ from the clean snapshot.
30
31
32
|
# File 'lib/kube/cluster/resource/dirty_tracking.rb', line 30
def patch_data
deep_diff(to_h, @clean)
end
|
#respond_to_missing?(name, include_private = false) ⇒ Boolean
34
35
36
37
38
39
40
|
# File 'lib/kube/cluster/resource/dirty_tracking.rb', line 34
def respond_to_missing?(name, include_private = false)
if name.end_with?("_changed?")
true
else
super
end
end
|