[Nitro] before-hook doesn't work anymore

Bryan Soto bryan.a.soto at gmail.com
Sun Nov 20 15:17:56 EST 2005


The problem seems to be caused by including Timestamped before any
properties.

The attached script shows the ancestors (method lookup) of two classes, one
with Timestamped included before properties (ClassOne) and one defining
properties first, then including Timestamped (ClassTwo).

It looks like by including Timestamped first, it triggers this line in
glue/property.rb

# Line 220 of glue/property.rb
m.send(:include, Glue::Aspects) unless m.ancestors.include?(Glue::Aspects)

which prevents Aspects from being included in ClassOne.

At least if you look at the class instance level ancestors (class << self
line. Not sure what that's called), they don't include
Glue::Aspects::ClassMethods.

Commenting out the unless clause in Line 220 makes the method lookup match.
I'm not sure if that's correct though.

bryan

On 11/20/05, George Moschovitis <george.moschovitis at gmail.com> wrote:
>
> Strange, will investigate this when I go to the office, howeverI have
> a lot of code with before aspect that works with 0.25.0...
>
> will let you know.
> -g.
>
>
> On 11/20/05, Michael Fellinger <m.fellinger at gmail.com> wrote:
> > Hey brian,
> >
> > It's a quite simple case:
> >
> > class OgFile
> > is Timestamped
> > property :filename, String
> > property :path, String
> > property :file, String
> > property :filesize, Integer
> > before %{ FileUtils.rm(@file) if $options[:rm_delete] }, :on =>
> [:og_delete]
> >
> > # the *args is mainly for later additional objects. (see OgImage below)
> >
> > def fill(*args)
> > file = args[0]
> > @filename = file.original_filename
> > @filesize = file.size
> > @path = File.join($options[:uploads_public], @filename)
> > @file = File.join($options[:uploads_relative], @filename)
> >
> > puts "copy #{file.path} to #{@file}" if $DBG
> > FileUtils.cp(file.path, @file)
> > end
> >
> > def to_s
> > "<a href='/#{@path}'>#{@filename}</a>"
> > end
> > end
> >
> >
> > Am Samstag 19 November 2005 19:05 schrieb Bryan Soto:
> > > Hi,
> > >
> > > Only way I can get a NoMethodError for before is if I call it before
> any
> > > properties are defined. I don't think that's your problem since you
> said
> > > you're upgrading.
> > >
> > > Could you share the model.rb file? Or at least a small portion that
> causes
> > > the same error?
> > >
> > > Re: super, you've pretty much got it. method_missing is called if a
> class
> > > or it's super-classes don't define a method. That's how we get
> George's fun
> > > find_by_such_and_such methods without having to define them. The super
> call
> > > in this case means "I don't know what to do with this message." and
> hands
> > > it off to the super class in case it does. And if it get's to Object,
> > > Object throws that nice little error message you got.
> > >
> > > The methods are actually defined (glue/lib/glue/aspects.rb). I don't
> think
> > > there is any method_missing magic for aspects.
> > >
> > > bryan
> > >
> > > On 11/19/05, Michael Fellinger <m.fellinger at gmail.com> wrote:
> > > > Hey list,
> > > >
> > > > I have one serious problem with switching to 0.25.0 here.
> > > > when i try to use this hook:
> > > >
> > > > before { puts "doesn't work" }, :on [:og_delete]
> > > >
> > > > i get following nice error at startup, and nitro shuts down.
> > > >
> > > > /usr/lib/ruby/gems/1.8/gems/og-0.25.0/lib/og/entity.rb:376:in
> > > > `method_missing': undefined method `before' for OgFile:Class
> > > > (NoMethodError)
> > > > from ./src/model.rb:30
> > > > from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:21:in
> > > > `require'
> > > > from /var/www/current/nixel/public/../run.rb:11
> > > > from /var/www/current/nixel/public/fcgi.rb:6
> > > >
> > > >
> > > > well, having this error wouldn't be that bad, if it wasn't a very
> special
> > > > error - it points to method_missing (more correct - line 376) and
> what is
> > > > in
> > > > this line:
> > > >
> > > > super
> > > >
> > > > that's it. No idea what voodoo is going on here - my ruby-instinct
> says
> > > > me that this is an inherited class/module and takes the
> method_missing of
> > > > the previous class in this special case. (i guess when in this
> > > > method_missing no
> > > > rule is defined for 'before') and now it fails even in the previous
> > > > defined
> > > > (if there is one defined... maybe it's only a call to an
> error-method?)
> > > >
> > > > can somebody help me on this?
> > > >
> > > > thx in pre,
> > > > manveru
> > > >
> > > >
> > > > _______________________________________________
> > > > Nitro-general mailing list
> > > > Nitro-general at rubyforge.org
> > > > http://rubyforge.org/mailman/listinfo/nitro-general
> >
> >
> > _______________________________________________
> > Nitro-general mailing list
> > Nitro-general at rubyforge.org
> > http://rubyforge.org/mailman/listinfo/nitro-general
> >
> >
> >
> >
>
>
> --
> http://www.gmosx.com
> http://www.navel.gr
> http://www.nitrohq.com
>
> _______________________________________________
> Nitro-general mailing list
> Nitro-general at rubyforge.org
> http://rubyforge.org/mailman/listinfo/nitro-general
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/nitro-general/attachments/20051120/0880a6be/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: aspect_test.rb
Type: application/octet-stream
Size: 421 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/nitro-general/attachments/20051120/0880a6be/attachment.obj 


More information about the Nitro-general mailing list