Class: Merb::BootLoader::MixinSessionContainer
- Inherits:
-
Merb::BootLoader
- Object
- Merb::BootLoader
- Merb::BootLoader::MixinSessionContainer
- Defined in:
- lib/merb-core/bootloader.rb
Class Method Summary collapse
-
.check_for_secret_key ⇒ Object
Attempts to set the session secret key.
-
.check_for_session_id_key ⇒ Object
Sets the controller session ID key if it has been set in config.
-
.run ⇒ Object
Mixin the correct session container.
Methods inherited from Merb::BootLoader
after, after_app_loads, before, before_app_loads, default_framework, inherited, move_klass
Class Method Details
.check_for_secret_key ⇒ Object
Attempts to set the session secret key. This method will exit if the key does not exist or is shorter than 16 charaters.
526 527 528 529 530 531 532 |
# File 'lib/merb-core/bootloader.rb', line 526 def self.check_for_secret_key unless Merb::Config[:session_secret_key] && (Merb::Config[:session_secret_key].length >= 16) Merb.logger.warn("You must specify a session_secret_key in your merb.yml, and it must be at least 16 characters\nbailing out...") exit! end Merb::Controller._session_secret_key = Merb::Config[:session_secret_key] end |
.check_for_session_id_key ⇒ Object
Sets the controller session ID key if it has been set in config.
518 519 520 521 522 |
# File 'lib/merb-core/bootloader.rb', line 518 def self.check_for_session_id_key if Merb::Config[:session_id_key] Merb::Controller._session_id_key = Merb::Config[:session_id_key] end end |
.run ⇒ Object
Mixin the correct session container.
476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 |
# File 'lib/merb-core/bootloader.rb', line 476 def self.run Merb.register_session_type('memory', Merb.framework_root / "merb-core" / "dispatch" / "session" / "memory", "Using in-memory sessions; sessions will be lost whenever the server stops.") Merb.register_session_type('memcache', Merb.framework_root / "merb-core" / "dispatch" / "session" / "memcached", "Using 'memcached' sessions") Merb.register_session_type('cookie', # Last session type becomes the default Merb.framework_root / "merb-core" / "dispatch" / "session" / "cookie", "Using 'share-nothing' cookie sessions (4kb limit per client)") Merb::Controller.class_eval do session_store = Merb::Config[:session_store].to_s if ["", "false", "none"].include?(session_store) Merb.logger.warn "Not Using Sessions" elsif reg = Merb.registered_session_types[session_store] if session_store == "cookie" Merb::BootLoader::MixinSessionContainer.check_for_secret_key Merb::BootLoader::MixinSessionContainer.check_for_session_id_key end require reg[:file] include ::Merb::SessionMixin Merb.logger.warn reg[:description] else Merb.logger.warn "Session store not found, '#{Merb::Config[:session_store]}'." Merb.logger.warn "Defaulting to CookieStore Sessions" Merb::BootLoader::MixinSessionContainer.check_for_secret_key Merb::BootLoader::MixinSessionContainer.check_for_session_id_key require Merb.registered_session_types['cookie'][:file] include ::Merb::SessionMixin Merb.logger.warn "(plugin not installed?)" end end Merb.logger.flush end |