Module: OpenHAB::RSpec::Mocks::PersistenceService::PersistedState

Defined in:
lib/openhab/rspec/mocks/persistence_service.rb

Instance Method Summary collapse

Instance Method Details

#timestampObject



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/openhab/rspec/mocks/persistence_service.rb', line 32

def timestamp
  # PersistenceExtensions uses an anonymous class to wrap the current
  # state if that happens to be an answer. Except it calls
  # ZonedDateTime.now in Java land, bypassing Timecop.
  # Detect that and make the call in Ruby
  #
  jc = @historic_item.class.java_class
  return ZonedDateTime.now if jc.anonymous? && jc.enclosing_class == PersistenceExtensions.java_class

  super
end