Hi,
I've a portion of code (a checksum) which is commonly used in a
specific app I just did. I've dozens of models, if not more, and for
each I've been copying the portion of code.
This seemed to be a good place for a DRY approach, by either using
mixins or plugins. I've questions.
- which one would be easier ? I did not manage to make a clean mixin,
since I need to invoke some methods like columns().
- developping a local plugin (without inserting it back into the gem)
seems interesting, but then how to load it ?
- I did not manage to find proper guidelines for developping plugins.
Is there such guideline ?
It seems that this is the bare minimum to have in most plugins I saw:
module Sequel
module Plugins
module MyOwnChecksum
def self.apply(model, opts={}, &block)
model.send(:include, ::MyOwnChecksum)
end
def self.configure(model, opts={}, &block)
end
module ClassMethods
end
module InstanceMethods
end
module DatasetMethods
end
end
end
end
- Is this a decent/correct skeleton ?
- I need to memoize in a class variable the columns list (I'm making a
custom checksum, excluding some columns and therefore I do not wish to
calculate at each checksum the list of columns to exclude). How to
insert this class variable inside the plugin ?
--
Christian
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sequel-talk?hl=en.