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

Mark Van De Vyver mvyver at gmail.com
Mon Sep 10 00:55:47 EDT 2007


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


More information about the Nitro-general mailing list