[Nitro] Error handling in ann_attr

transfire at gmail.com transfire at gmail.com
Thu Feb 8 21:45:42 EST 2007



On Feb 8, 6:28 pm, "nya... at gmail.com" <nya... at gmail.com> wrote:
> As a quickie:  here's my buggy code:
>
> class Hosted
>   attr_accessor :response, HTTPResponse
> end
>
> Amusingly, this added #response, #response=, #HTTPReponse and
> #HTTPResponse=
>
> So first of all, I'm fascinated by how facets snagged the name of the
> bogus constant I passed, but more significantly, I wish it had noticed
> that what I meant to do was annotate :response with a class, and had
> left off the module namespace.
>
> I'm architecturally uncertain as to whether that catch belongs in
> Facets or in Og, or I'd submit a patch.
>
> (On that note, George: I'm assuming that the repo is still unstable
> and I should put off patch work until it's stable again?)

Appearently Og is still using that old missing_constant return symbol
trick! The idea is that it allows you to define a model prior to the
actual constant being defined. Clever, but as you have now discovered
this is TOO magical and no longer even works with the new
implementation of annotated attrs. If there is the chance that the
constant will not be defined before your model needs it then use the
equivalent full spec:

  attr_accessor :response, :class => :HTTPResponse

That should work (if not it's a bug that needs to be fixed).

T.



More information about the Nitro-general mailing list