Class: Authorizy::Config
- Inherits:
-
Object
- Object
- Authorizy::Config
- Defined in:
- lib/authorizy/config.rb
Instance Attribute Summary collapse
-
#aliases ⇒ Object
Returns the value of attribute aliases.
-
#cop ⇒ Object
Returns the value of attribute cop.
-
#current_user ⇒ Object
Returns the value of attribute current_user.
-
#denied ⇒ Object
Returns the value of attribute denied.
-
#dependencies ⇒ Object
Returns the value of attribute dependencies.
-
#field ⇒ Object
Returns the value of attribute field.
-
#redirect_url ⇒ Object
Returns the value of attribute redirect_url.
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/authorizy/config.rb', line 7 def initialize @aliases = {} @cop = Authorizy::BaseCop @current_user = ->(context) { context.respond_to?(:current_user) ? context.current_user : nil } @denied = lambda { |context| info = I18n.t('authorizy.denied', controller: context.params[:controller], action: context.params[:action]) return context.redirect_to(redirect_url.call(context), info:) if context.request.format.html? context.render(json: { message: info }, status: 403) } @dependencies = {} @field = ->(current_user) { current_user.respond_to?(:authorizy) ? current_user. : {} } @redirect_url = ->(context) { context.respond_to?(:root_url) ? context.root_url : '/' } end |
Instance Attribute Details
#aliases ⇒ Object
Returns the value of attribute aliases.
5 6 7 |
# File 'lib/authorizy/config.rb', line 5 def aliases @aliases end |
#cop ⇒ Object
Returns the value of attribute cop.
5 6 7 |
# File 'lib/authorizy/config.rb', line 5 def cop @cop end |
#current_user ⇒ Object
Returns the value of attribute current_user.
5 6 7 |
# File 'lib/authorizy/config.rb', line 5 def current_user @current_user end |
#denied ⇒ Object
Returns the value of attribute denied.
5 6 7 |
# File 'lib/authorizy/config.rb', line 5 def denied @denied end |
#dependencies ⇒ Object
Returns the value of attribute dependencies.
5 6 7 |
# File 'lib/authorizy/config.rb', line 5 def dependencies @dependencies end |
#field ⇒ Object
Returns the value of attribute field.
5 6 7 |
# File 'lib/authorizy/config.rb', line 5 def field @field end |
#redirect_url ⇒ Object
Returns the value of attribute redirect_url.
5 6 7 |
# File 'lib/authorizy/config.rb', line 5 def redirect_url @redirect_url end |