about summary refs log tree commit diff
path: root/app/lib
diff options
context:
space:
mode:
Diffstat (limited to 'app/lib')
-rw-r--r--app/lib/settings/extend.rb9
-rw-r--r--app/lib/settings/scoped_settings.rb12
2 files changed, 21 insertions, 0 deletions
diff --git a/app/lib/settings/extend.rb b/app/lib/settings/extend.rb
new file mode 100644
index 000000000..7241a1221
--- /dev/null
+++ b/app/lib/settings/extend.rb
@@ -0,0 +1,9 @@
+module Settings
+  module Extend
+  	extend ActiveSupport::Concern
+
+    def settings
+      ScopedSettings.for_thing(self)
+    end
+  end
+end
\ No newline at end of file
diff --git a/app/lib/settings/scoped_settings.rb b/app/lib/settings/scoped_settings.rb
new file mode 100644
index 000000000..f8f22a91b
--- /dev/null
+++ b/app/lib/settings/scoped_settings.rb
@@ -0,0 +1,12 @@
+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
\ No newline at end of file