Project

General

Profile

Bug #1438

easy settings for plugins

Added by cpg about 6 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
06/13/2014
Due date:
% Done:

0%


Description

we need to make an api to make plugins easier

one example is to provice a way to make it dead-easy for plugins to safely have Settings of its own.

e.g. imagine a PluginSetting class

we make it easy to store and retrieve basic DB-backed types for a plugin,
like strings, integers and even arrays

example, say we need a setting in a plugin that is just a checkbox, say, to enable a feature

PluginSetting.new(key, value) (key is a string, value can be a number of things)

s = PluginSetting.new(“fancysetting”, true)
s.set(false)
s.set(true)
s.value => true

eg for arrays: we could do something like this

    PluginSettings.new("key", [“event”, Time.now])

    s << [“event2", Time.now]

    s << [“event3”, nil]

    s.value =>  [[“event”, Time.now], [“event2", Time.now], [“event3”, nil]]

(i am sure this is not correct -- but hope you get the idea)

at the uninstallation of the plugin, the PluginSettings for that plugin are nuked

it can be implemented using Setting, by having a special value in the "kind" column:

https://github.com/amahi/platform/blob/master/db/schema.rb#L114

each plugin must have a unique value for the kind column. typically it's the app identifier that contains that plugin.

i.e., the kind column can be use to indicate who owns that setting

the PluginSettings isolates the plugin to all the implementation above.

Also available in: Atom