From 6f6a0b28760161e4111239577489ce29d4b5c2e3 Mon Sep 17 00:00:00 2001 From: Alexander Olofsson <alexander.olofsson@liu.se> Date: Tue, 16 May 2023 09:08:43 +0200 Subject: [PATCH] Expose Resource#modified? as public Can be useful when doing conditional saving of resources or similar functionality --- lib/passwordstate/resource.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/passwordstate/resource.rb b/lib/passwordstate/resource.rb index 4601c2b..77a5467 100644 --- a/lib/passwordstate/resource.rb +++ b/lib/passwordstate/resource.rb @@ -151,6 +151,12 @@ module Passwordstate end end + def modified?(field = nil) + return modified.any? unless field + + modified.include? field + end + protected def api_path @@ -162,10 +168,6 @@ module Passwordstate attribs.reject { |field| old[field] == attribs[field] } end - def modified?(field) - modified.include? field - end - def old @old ||= attributes.dup end -- GitLab