[Nitro] injecting Og functionality
Antoniolo
antoniolo at gmail.com
Wed Mar 14 13:01:13 EDT 2007
I think model needs to be refactored as soon as possible.
The current way to insert an Og functionally in a regular object is
including the module ModelMixin, extending Og::Model or using
attr_accessor/property, right?
imho, the problems begins there.
The last one, inside ann_attr.rb, there's a callback to customize the
default attr_accessor behaviour. Basically speaking, it places the Og
funcionalitty through:
target.send(:include, Og::ModelMixin) if ....
target.send(:include, Og::Mixin::Validation)...
In fact, ModelMixin as far as I can guess is nothing more than
instance_methods/class_methods for Model Class (modularized code).
Validation is also other piece of code regarding only to Model class. My
point is: the injecting mechanism is knowing much about model's. You know,
if we add more and more functionality to models, we'll end up having to
update the injection mechanism as well as the model by itself.
I can leisurely guess the initial idea of Og is to place the functionality
in models seamlessly. I mean without any explicit inheritance mechanism. But
I think it's not too ulgy to use it in application-side:
class Person < Og::Model
end
After all, we can rename ModelMixin to its real purpose (InstanceMethods,
ClassMethods).
Those Mixinz, I mean Cacheable and its friends, are they all supposed to be
extended functionally(plugin)? Similar to acts_as(activerecord)?
Well, this is my interpretation from the code ... I'm not sure what I said
makes any sense.
More information about the Nitro-general
mailing list