Module: Legion::Extensions::Actors::Fingerprint
Instance Method Summary collapse
- #compute_fingerprint ⇒ Object
- #fingerprint_source ⇒ Object
- #skip_if_unchanged? ⇒ Boolean
- #skip_or_run ⇒ Object
- #store_fingerprint! ⇒ Object
- #unchanged? ⇒ Boolean
Instance Method Details
#compute_fingerprint ⇒ Object
19 20 21 |
# File 'lib/legion/extensions/actors/fingerprint.rb', line 19 def compute_fingerprint Digest::SHA256.hexdigest(fingerprint_source.to_s) end |
#fingerprint_source ⇒ Object
13 14 15 16 17 |
# File 'lib/legion/extensions/actors/fingerprint.rb', line 13 def fingerprint_source bucket = respond_to?(:time) ? time.to_i : 60 bucket = 1 if bucket < 1 (Time.now.utc.to_i / bucket).to_s end |
#skip_if_unchanged? ⇒ Boolean
9 10 11 |
# File 'lib/legion/extensions/actors/fingerprint.rb', line 9 def skip_if_unchanged? false end |
#skip_or_run ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/legion/extensions/actors/fingerprint.rb', line 33 def skip_or_run if skip_if_unchanged? && unchanged? Legion::Logging.debug "#{self.class} skipped: fingerprint unchanged (#{@last_fingerprint[0, 8]}...)" return end yield store_fingerprint! end |
#store_fingerprint! ⇒ Object
29 30 31 |
# File 'lib/legion/extensions/actors/fingerprint.rb', line 29 def store_fingerprint! @last_fingerprint = compute_fingerprint end |
#unchanged? ⇒ Boolean
23 24 25 26 27 |
# File 'lib/legion/extensions/actors/fingerprint.rb', line 23 def unchanged? return false if @last_fingerprint.nil? compute_fingerprint == @last_fingerprint end |