Module: SimpleAuth::ActionController::ClassMethods
- Defined in:
- lib/simple_auth/action_controller.rb
Instance Method Summary collapse
-
#install_simple_auth_scope(scope) ⇒ Object
rubocop:disable Metrics/MethodLength.
- #install_simple_auth_scopes ⇒ Object
Instance Method Details
#install_simple_auth_scope(scope) ⇒ Object
rubocop:disable Metrics/MethodLength
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/simple_auth/action_controller.rb', line 19 def install_simple_auth_scope(scope) # rubocop:disable Metrics/MethodLength class_eval <<-RUBY, __FILE__, __LINE__ + 1 def #{scope}_session @#{scope}_session ||= Session.create(scope: :#{scope}, session: session) end def current_#{scope} #{scope}_session.record end def #{scope}_logged_in? current_#{scope}.present? end RUBY define_method "authorized_#{scope}?" do true end define_method "require_logged_#{scope}" do simple_auth_require_logged_scope(scope) end define_method "redirect_logged_#{scope}" do simple_auth_redirect_logged_scope(scope) end end |
#install_simple_auth_scopes ⇒ Object
12 13 14 15 16 17 |
# File 'lib/simple_auth/action_controller.rb', line 12 def install_simple_auth_scopes SimpleAuth.config.scopes.each do |scope| install_simple_auth_scope(scope) helper_method "current_#{scope}", "#{scope}_logged_in?" end end |