Sha256: 45f5533535e8035e29660a9a7849ffb79e00a6aa63d407d9f06a6baaaf05f296

Contents?: true

Size: 1.25 KB

Versions: 1

Compression:

Stored size: 1.25 KB

Contents

if defined?(Merb::Plugins)
  Merb::Plugins.config[:merb_sequel] = {}
  require File.join(File.dirname(__FILE__) / "sequel_ext" / "model")
  require File.join(File.dirname(__FILE__) / "merb" / "orms" / "sequel" / "connection")
  Merb::Plugins.add_rakefiles "merb_sequel" / "merbtasks"
  
  class Merb::Orms::Sequel::Connect < Merb::BootLoader

    after BeforeAppLoads

    def self.run
      Merb::Orms::Sequel.connect
      if Merb::Config.session_stores.include?(:sequel)
        Merb.logger.debug "Using Sequel sessions"
        require File.join(File.dirname(__FILE__) / "merb" / "session" / "sequel_session")
      end
      
      Merb::Router.root_behavior = Merb::Router.root_behavior.identify(Sequel::Model => :pk)
    end

  end
  
  class Merb::Orms::Sequel::DisconnectBeforeFork < Merb::BootLoader
    after AfterAppLoads
    
    def self.run
      Merb.logger.debug "Disconnecting database connection before forking."
      ::Sequel::DATABASES.each { |db| db.disconnect }
    end
    
  end
  
  generators = File.join(File.dirname(__FILE__), 'generators')
  Merb.add_generators generators / :migration
  Merb.add_generators generators / :model
  Merb.add_generators generators / :resource_controller
  Merb.add_generators generators / :session_migration
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
merb_sequel-1.0.0 lib/merb_sequel.rb