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, finished?, 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.
605 606 607 608 609 610 611 |
# File 'lib/merb-core/bootloader.rb', line 605 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 init file, 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.
597 598 599 600 601 |
# File 'lib/merb-core/bootloader.rb', line 597 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.
557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 |
# File 'lib/merb-core/bootloader.rb', line 557 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] Merb::BootLoader::MixinSessionContainer.check_for_secret_key if session_store == "cookie" Merb::BootLoader::MixinSessionContainer.check_for_session_id_key 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 |