diff options
Diffstat (limited to 'app/lib')
-rw-r--r-- | app/lib/settings/extend.rb | 9 | ||||
-rw-r--r-- | app/lib/settings/scoped_settings.rb | 12 |
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 |