Class: Merb::BootLoader::SetupSession

Inherits:
Merb::BootLoader show all
Defined in:
lib/merb-core/bootloader.rb

Class Method Summary collapse

Methods inherited from Merb::BootLoader

after, after_app_loads, before, before_app_loads, before_master_shutdown, before_worker_shutdown, default_framework, finished?, inherited, move_klass

Class Method Details

.runObject

Enable the configured session container(s); any class that inherits from SessionContainer will be considered by its session_store_type attribute.

Returns

nil

:api: plugin



1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
# File 'lib/merb-core/bootloader.rb', line 1222

def self.run
  # Require all standard session containers.
  Dir[Merb.framework_root / "merb-core" / "dispatch" / "session" / "*.rb"].each do |file|
    base_name = File.basename(file, ".rb")
    require file unless base_name == "container" || base_name == "store_container"
  end

  # Set some defaults.
  Merb::Config[:session_id_key] ||= "_session_id"

  # List of all session_stores from :session_stores and :session_store config options.
  config_stores = Merb::Config.session_stores

  # Register all configured session stores - any loaded session container class
  # (subclassed from Merb::SessionContainer) will be available for registration.
  Merb::SessionContainer.subclasses.each do |class_name|
    if(store = Object.full_const_get(class_name)) &&
      config_stores.include?(store.session_store_type)
        Merb::Request.register_session_type(store.session_store_type, class_name)
    end
  end

  # Mixin the Merb::Session module to add app-level functionality to sessions
  overrides = (Merb::Session.instance_methods & Merb::SessionContainer.instance_methods)
  overrides.each do |m| 
    Merb.logger.warn!("Warning: Merb::Session##{m} overrides existing " \
                      "Merb::SessionContainer##{m}")
  end    
  Merb::SessionContainer.send(:include, Merb::Session)
  nil
end