Module: OpenHAB::RSpec::Mocks::PersistenceService::HistoricState

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

Instance Method Summary collapse

Instance Method Details

#timestampObject



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/openhab/rspec/mocks/persistence_service.rb', line 23

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