A couple of discussions later I propose the attached patch for Engines.

This super-minimalistic approach allows to do two things:

1. Plugin users can set plugin attribute values in a file [plugin_dir]/ config.yml. If the file is present, it will be parsed and values loaded. If an attribute for a YAML name/value pair hasn't been defined by the plugin dev (see 2.)) it will be defined.

# [plugin_dir]/config.yml
something: cool

2. Plugin devs can define attributes and default values in init.rb (or elsewhere in the plugin as long as they make sure that the definition is evaluated when the plugin's init.rb is) like this:

attr_accessor :something
@something = 'default'

The mechanism works both when 1.) no config.yml is present and when 2.) no default values have been set by the plugin dev.

I think this is a great solution because it's flexible, minimalistic and unobstrusive.

Apps like Mephisto can then build further on this mechanism and add another storage layer on top of this. E.g. Mephisto could overwrite Engine::Plugin#load_config_data and access the database to load an AR object holding the config data.

Unit tests for this are ready. Please let me know what you think!

I'd like to proceed with this stuff as soon as possible so I can start porting/implementing changes for Mephisto.

Attachment: plugin_attributes.diff
Description: Binary data



--
sven fuchs                      [EMAIL PROTECTED]
artweb design           http://www.artweb-design.de
grünberger 65           + 49 (0) 30 - 47 98 69 96 (phone)
d-10245 berlin          + 49 (0) 171 - 35 20 38 4 (mobile)



_______________________________________________
Engine-Developers mailing list
[email protected]
http://lists.rails-engines.org/listinfo.cgi/engine-developers-rails-engines.org

Reply via email to