Module: GlobalSession::Rails::ActionControllerClassMethods
- Defined in:
- lib/global_session/rails/action_controller_class_methods.rb
Overview
Module that is mixed into ActionController’s eigenclass; provides access to shared app-wide data such as the configuration object, and implements the DSL used to configure controllers’ use of the global session.
Constant Summary collapse
- VALID_OPTIONS =
[:raise, :renew, :only, :except]
- DEFAULT_OPTIONS =
{ :raise=>true, :renew=>true }
Instance Method Summary collapse
- #global_session_options ⇒ Object
- #global_session_options=(options) ⇒ Object
- #has_global_session(options = {}) ⇒ Object
- #no_global_session ⇒ Object
Instance Method Details
#global_session_options ⇒ Object
62 63 64 65 66 67 68 69 70 |
# File 'lib/global_session/rails/action_controller_class_methods.rb', line 62 def if elsif self.superclass.respond_to?(:global_session_options) self.superclass. else {} end end |
#global_session_options=(options) ⇒ Object
72 73 74 |
# File 'lib/global_session/rails/action_controller_class_methods.rb', line 72 def () = end |
#has_global_session(options = {}) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/global_session/rails/action_controller_class_methods.rb', line 34 def has_global_session(={}) #validate our options .assert_valid_keys(VALID_OPTIONS) if .key?(:only) && .key?(:except) raise ArgumentError, "Must specify :only OR :except, you specified both" end #start with default options; merge any options inherited from our base class; #merge any options provided by the caller. obase = self.superclass. = DEFAULT_OPTIONS.merge(obase).merge() #ensure derived-class options don't conflict with mutually exclusive base-class options .delete(:only) if obase.has_key?(:only) && .has_key?(:except) .delete(:except) if obase.has_key?(:except) && .has_key?(:only) #mark the global session as enabled (a hidden option) and store our #calculated, merged options [:enabled] = true self. = end |
#no_global_session ⇒ Object
57 58 59 60 |
# File 'lib/global_session/rails/action_controller_class_methods.rb', line 57 def no_global_session #mark the global session as not-enabled (a hidden option) self.={:enabled=>false} end |