Sourcereload

5 views
Skip to first unread message

Tamas

unread,
Jun 13, 2008, 6:16:23 AM6/13/08
to Ramaze
Since it's my first post on this forum I'd like to thank You all this
great framework!

My question: Could someone explain me how to use
Sourcereload.trait :reload_glob?

I'd like to exclude ./model or explicitly include the controllers and
some files only but I can't use it properly. Anyway the problem is
that Sequel adds hooks again on every reload so they run several times
instead of only once.

So where and how to use it? I tried this way before Ramaze.start:
Ramaze::SourceReload.trait :reload_glob => Regexp.new(Dir.pwd << '\/
controller')

Any hints?

Tamas

Michael Fellinger

unread,
Jun 13, 2008, 6:28:34 AM6/13/08
to ram...@googlegroups.com
On Fri, Jun 13, 2008 at 7:16 PM, Tamas <tamas...@googlemail.com> wrote:
>
> Since it's my first post on this forum I'd like to thank You all this
> great framework!
>
> My question: Could someone explain me how to use
> Sourcereload.trait :reload_glob?
>
> I'd like to exclude ./model or explicitly include the controllers and
> some files only but I can't use it properly. Anyway the problem is
> that Sequel adds hooks again on every reload so they run several times
> instead of only once.

Common problem, run hooks.clear before declaring hooks, same goes for
validations.

Jeremy Evans

unread,
Jun 13, 2008, 11:24:37 AM6/13/08
to Ramaze
On Jun 13, 3:16 am, Tamas <tamas.de...@googlemail.com> wrote:
> Since it's my first post on this forum I'd like to thank You all this
> great framework!
>
> My question: Could someone explain me how to use
> Sourcereload.trait :reload_glob?
>
> I'd like to exclude ./model or explicitly include the controllers and
> some files only but I can't use it properly. Anyway the problem is
> that Sequel adds hooks again on every reload so they run several times
> instead of only once.

You need to include a tag with the hooks so it doesn't add them
multiple times:

class Blah < Sequel::Model
before_save(:do_something){...}
end

That should make hooks work OK with source reloading.

Jeremy

Tamas

unread,
Jun 17, 2008, 3:11:05 AM6/17/08
to Ramaze
Thanks Jeremy! It's a nice solution!

But what about validations? As Michael wrote it's problematic also
with Sourcereload.

Tom

Jeremy Evans

unread,
Jun 18, 2008, 11:01:17 AM6/18/08
to Ramaze
On Jun 17, 12:11 am, Tamas <tamas.de...@googlemail.com> wrote:
> Thanks Jeremy! It's a nice solution!
>
> But what about validations? As Michael wrote it's problematic also
> with Sourcereload.

I suppose a similar thing could work, but the validations code would
need substantial changes. I've added looking into the possibility to
my todo list for Sequel 2.2.

Jeremy
Reply all
Reply to author
Forward
0 new messages