about summary refs log tree commit diff
path: root/app/lib/settings/scoped_settings.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/lib/settings/scoped_settings.rb')
-rw-r--r--app/lib/settings/scoped_settings.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/app/lib/settings/scoped_settings.rb b/app/lib/settings/scoped_settings.rb
new file mode 100644
index 000000000..82b70d128
--- /dev/null
+++ b/app/lib/settings/scoped_settings.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+module Settings
+  class ScopedSettings < ::Setting
+    def self.for_thing(object)
+      @object = object
+      self
+    end
+
+    def self.thing_scoped
+      unscoped.where(thing_type: @object.class.base_class.to_s, thing_id: @object.id)
+    end
+  end
+end