[Nitro] OG RFC: Manager-Store-Adapter options and new store_details attr

Mark Van De Vyver mvyver at gmail.com
Mon Sep 10 04:59:08 EDT 2007


Hi George,
On 9/10/07, George Moschovitis <george.moschovitis at gmail.com> wrote:
> Let me think a bit about this and i will get back to you. Things are kinf of
> hectic here. Thanks for your work and useful posts to this list.

Hmm, don't speak too soon I could turn into more hindrance than help :)

There are two issues really:

1) Syncing the manager and store/adapter options listing (this I'm
really not sure about).  I just do this using the store_details hash
because its within my skill set ;) (but I am worried about two objects
sharing a hash - it doesn't feel right - probably just fear out of
ignorance)

2) Providing a method that allows someone using an instance of an
adapter to get information about what that adapter has setup(for this
I do like the store_details hash idea, but I now wonder if that should
be 'adapter_details', in case later on some 'elaborate' store needs
'store_details').  I the case of DBI this '*_details' hash will (I
think) be very useful, and keep the DbiAdapter flexibile (certain dbi
drivers allow you to configure/set/activate particular 'things' and we
should let people do just this if they want? and if it is done it
would be easy to find out about what has been done)  Also it is only
once a store is fully set up by the <vendor>Adapter that we'll know
for sure what 'state' it is in.  Dynamically creating methods that
return the values that would otherwise be in the store_details hash
might work best? But, is more complicated(?)  we'll just be replacing:
special_method if store_details[:special_option]
with
special_method if responds_to?(...) # or method_missing?


OK, of the synching issue:
If Og::Manager was a module and included/extended into Store, then it
might be possible to use the (Facets) Kernel.as(..).method I've seen
described here: http://rubyurl.com/Oai
But the Store would get 'cluttered' and one comment suggests there may
to be some memory leak issue?  I prefer the idea of not including or
extending Manager into Store - they seem very different objects to me.

I also wasn't sure how, or whether, the Advice 'before' and 'after'
discussed in the list would help with the synchronization issue - I'd
be interested in knowing if it's possible.

Cheers
Mark

> regards,
> George.
>
>
> On 9/10/07, Mark Van De Vyver <mvyver at gmail.com> wrote:
> >
> > Hi,
> > As you'd have seen from some earlier emails, I've been getting up to
> > speed on the OG Manager-Store-Adapter relation.
> >
> > Currently, start-up options are passed from manger to adapter and
> > immediately are out of sync: manage.options indicates nothing about
> > the options that store has used.  Store @options isn't readable or
> > settable.  To sync and provide some flexibility I'll need later I
> > thought to make the following changes - these shouldn't break existing
> > behavior, and are the smallest I could come up with that give the
> > flexibility I think I'll need.
> >
> > Maybe use details instead of store_details?
> >
> > Comments welcome.
> >
> > Mark
> >
> > # start ruby script
> >
> > require "pp"
> >
> > module Og
> >
> >   class Manager
> >     attr_accessor :options
> >     attr_accessor :store
> >     def initialize(options)
> >
> >       @store = Adapter.new(options)
> >       # new sync manager and store options data
> >       @options = @store.store_details[:options]
> >     end
> >   end
> >
> >   class Store
> >
> >     attr_accessor :ogmanager
> >     attr_accessor :store_details # new
> >
> >     def initialize(options)
> >       @store_details={} # new
> >       @store_details[:options] ||= options # new
> >       @options = @store_details[:options] # same content & behavior
> >     end
> >
> >   end
> >
> >   class SQLstore < Store  # no changes here
> >     def initialize(options)
> >       super
> >     end
> >   end
> >
> >     class Adapter < SQLstore  # no changes here
> >
> >     def initialize(options)
> >       super
> >     end
> >
> >   end
> >
> > end
> >
> > @manager = Og::Manager.new({:adapter => :dbi})
> >
> > pp @manager.options
> > pp @manager.store.store_details[:options]
> > @manager.store.store_details[:dbi_driver]=:mysql
> > pp @manager.store.store_details
> > @manager.store.store_details[:options][:dbi_driver]=:mysql
> > pp @manager.options
> > pp @manager.store.store_details[:options]
> > pp @manager.store.store_details
> > pp @manager.options
> > @manager.options[:new]="option"
> > pp @manager.store.store_details[:options]
> > pp @ manager.options
> >
> > # end ruby script
> > _______________________________________________
> > Nitro-general mailing list
> > Nitro-general at rubyforge.org
> > http://rubyforge.org/mailman/listinfo/nitro-general
> >
>
>
>
> --
> http://www.me.gr
> http://phidz.com
>  http://blog.gmosx.com
> http://cull.gr
> http://www.joy.gr
> http://nitroproject.org


More information about the Nitro-general mailing list