Forum: Rails Engines development Engines & config

Posted by James Adam (Guest)
on 2006-10-16 14:10
(Received via mailing list)
Hello all,

So, finally (yes, yes, I know) a version of the engines plugin
approacheth targetted at edge rails (aiming at the 1.2 release). I'm
taking this opportunity to do some serious refactoring, so I thought
I'd solicit some opinions while I'm at it. There might be a few emails
like this in the very near future - feedback is appreciated.

Topic #1: Removing the 'config' method

I'm considering removing this method from engines as default. Or
rather, not attaching the 'config' method to the Module class when
engines loads. This might've been a bad idea since it can conflict
with the 'config' method of any other module out there, or even when
accessing Rails' config via the variable supplied during plugin's
init.rb evaluation (http://dev.rails-engines.org/tickets/187).

The purpose of the 'config' method was to make it simple for engine
developers to define defaults but allow users to override those
values, but I think now we might be able to adopt a more 'Railish'
approach by using mattr_accessor instead. So, rather than
(environment.rb):

  module SomeEngine
    config :something, <value>
  end
  Engines.start :some_engine

we might have

  Engines.start :some_engine
  SomeEngine.something = <value>

The user configuration would now occur after the engines are loaded,
so that the appropriate accessors ca be defined within the engine
itself.

Obviously this change is going to break existing engines (the config
method won't be there anymore) until they are updated, which needn't
be immediately. Any thoughts?

James
Posted by Jay Levitt (Guest)
on 2006-10-16 19:01
(Received via mailing list)
On Mon, 16 Oct 2006 13:09:15 +0100, James Adam wrote:

> The purpose of the 'config' method was to make it simple for engine
> developers to define defaults but allow users to override those
> values, but I think now we might be able to adopt a more 'Railish'
> approach by using mattr_accessor instead.

I think that sounds good.. no reason to reinvent the wheel.  The less
weight that Engines carries, the more likely it is to see wider 
adoption.
I've recently seen people who want "a plugin with views and controllers 
and
models" but, instinctively, feel that Engines is too heavyweight.  I
obviously disagree...

Jay
Posted by Justin Blake (Guest)
on 2006-10-16 23:57
(Received via mailing list)
On 10/16/06, James Adam <james.adam@gmail.com> wrote:
>   SomeEngine.something = <value>
>
> The user configuration would now occur after the engines are loaded,
> so that the appropriate accessors ca be defined within the engine
> itself.

I love it.
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.