From 35bca061e87b555710d7a3a3a718c07583d70392 Mon Sep 17 00:00:00 2001 From: Giallombardo Nathan Date: Wed, 14 Aug 2024 14:55:01 +0000 Subject: [PATCH] optimize dynamic attribute --- lib/couchbase-orm/attributes/dynamic.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/couchbase-orm/attributes/dynamic.rb b/lib/couchbase-orm/attributes/dynamic.rb index cec07850..a8d14121 100644 --- a/lib/couchbase-orm/attributes/dynamic.rb +++ b/lib/couchbase-orm/attributes/dynamic.rb @@ -15,7 +15,7 @@ module AttributesDynamic # # @return [ true | false ] True if it does, false if not. def respond_to?(name, include_private = false) - super || attributes&.key?(name.to_s.reader) + super || has_attribute?(name.to_s.reader) end private @@ -114,7 +114,7 @@ def define_dynamic_writer(name) # @return [ Object ] The result of the method call. def method_missing(name, *args) attr = name.to_s - return super unless attr.reader != 'id' && attributes.key?(attr.reader) + return super unless attr.reader != 'id' && has_attribute?(attr.reader) getter = attr.reader if attr.writer?