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
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/kube/cluster/resource/dirty_tracking.rb', line 37
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
11
12
13
|
# File 'lib/kube/cluster/resource/dirty_tracking.rb', line 11
def changed
diff_keys(to_h, @clean)
end
|
#changed? ⇒ Boolean
7
8
9
|
# File 'lib/kube/cluster/resource/dirty_tracking.rb', line 7
def changed?
to_h != @clean
end
|
#changes ⇒ Object
15
16
17
|
# File 'lib/kube/cluster/resource/dirty_tracking.rb', line 15
def changes
build_changes(to_h, @clean)
end
|
#changes_applied ⇒ Object
19
20
21
|
# File 'lib/kube/cluster/resource/dirty_tracking.rb', line 19
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.
25
26
27
|
# File 'lib/kube/cluster/resource/dirty_tracking.rb', line 25
def patch_data
deep_diff(to_h, @clean)
end
|
#respond_to_missing?(name, include_private = false) ⇒ Boolean
29
30
31
32
33
34
35
|
# File 'lib/kube/cluster/resource/dirty_tracking.rb', line 29
def respond_to_missing?(name, include_private = false)
if name.end_with?("_changed?")
true
else
super
end
end
|