REFACTOR: Instance methods added to 'PluginStore' model for easy access (#5315)

This commit is contained in:
Vinoth Kannan
2017-11-15 10:10:20 -05:00
committed by Robin Ward
parent c025fcffa5
commit cbc0afb399
2 changed files with 24 additions and 1 deletions
+18
View File
@@ -1,5 +1,23 @@
# API to wrap up plugin store rows
class PluginStore
attr_reader :plugin_name
def initialize(plugin_name)
@plugin_name = plugin_name
end
def get(key)
self.class.get(plugin_name, key)
end
def set(key, value)
self.class.set(plugin_name, key, value)
end
def remove(key)
self.class.remove(plugin_name, key)
end
def self.get(plugin_name, key)
if row = PluginStoreRow.find_by(plugin_name: plugin_name, key: key)
cast_value(row.type_name, row.value)