From 619b89975f15b6897b61bfa96c8955f248dc9cc9 Mon Sep 17 00:00:00 2001 From: Cody Cutrer Date: Sun, 23 Apr 2023 15:31:28 -0600 Subject: [PATCH] Avoid having to re-lookup Semantics::Property on every reference in 3.4.x (#66) Signed-off-by: Cody Cutrer --- lib/openhab/core/items/semantics.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/openhab/core/items/semantics.rb b/lib/openhab/core/items/semantics.rb index da1fb0fc0d..e655d0a3c2 100644 --- a/lib/openhab/core/items/semantics.rb +++ b/lib/openhab/core/items/semantics.rb @@ -491,6 +491,7 @@ def self.const_missing(sym) logger.trace("const missing, performing Semantics Lookup for: #{sym}") # @deprecated OH3.4 - the Property tag had an ID of "MeasurementProperty" in OH3.4. This was corrected in OH4. # make sure we compare against pre-release versions + target_sym = sym if sym == :Property && Gem::Version.new(Core::VERSION) < Gem::Version.new("4.0.0.M1") sym = :MeasurementProperty end @@ -499,7 +500,7 @@ def self.const_missing(sym) &.then do |tag| tag = tag.ruby_class tag.singleton_class.include(TagClassMethods) - const_set(sym, tag) + const_set(target_sym, tag) end end