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
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/kube/cluster/resource/dirty_tracking.rb', line 40
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
14
15
16
|
# File 'lib/kube/cluster/resource/dirty_tracking.rb', line 14
def changed
diff_keys(to_h, @clean)
end
|
#changed? ⇒ Boolean
10
11
12
|
# File 'lib/kube/cluster/resource/dirty_tracking.rb', line 10
def changed?
to_h != @clean
end
|
#changes ⇒ Object
18
19
20
|
# File 'lib/kube/cluster/resource/dirty_tracking.rb', line 18
def changes
build_changes(to_h, @clean)
end
|
#changes_applied ⇒ Object
22
23
24
|
# File 'lib/kube/cluster/resource/dirty_tracking.rb', line 22
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.
28
29
30
|
# File 'lib/kube/cluster/resource/dirty_tracking.rb', line 28
def patch_data
deep_diff(to_h, @clean)
end
|
#respond_to_missing?(name, include_private = false) ⇒ Boolean
32
33
34
35
36
37
38
|
# File 'lib/kube/cluster/resource/dirty_tracking.rb', line 32
def respond_to_missing?(name, include_private = false)
if name.end_with?("_changed?")
true
else
super
end
end
|