Class: Sqreen::Rules::RunUserActions

Inherits:
CB
  • Object
show all
Defined in:
lib/sqreen/rules/run_user_actions.rb

Overview

Runs the block_user actions (for hooking Sqreen.identify,auth_user)

Constant Summary

Constants inherited from CB

CB::DEFAULT_PRIORITY

Instance Attribute Summary

Attributes inherited from CB

#klass, #method, #overtimeable

Instance Method Summary collapse

Methods inherited from CB

#failing?, #framework, #overtime!, #post?, #pre?, #priority, #to_s, #whitelisted?

Constructor Details

#initialize(klass, method, auth_keys_idx) ⇒ RunUserActions

Returns a new instance of RunUserActions.



13
14
15
16
# File 'lib/sqreen/rules/run_user_actions.rb', line 13

def initialize(klass, method, auth_keys_idx)
  super(klass, method)
  @auth_keys_idx = auth_keys_idx
end

Instance Method Details

#post(_retval, _inst, args, _budget = nil) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/sqreen/rules/run_user_actions.rb', line 18

def post(_retval, _inst, args, _budget = nil)
  actions = actions_repo.get('block_user', args[@auth_keys_idx]) +
            actions_repo.get('redirect_user', args[@auth_keys_idx])

  actions.each do |action|
    res = action.run args[@auth_keys_idx]
    return res unless res.nil?
  end
  nil
end