class Sqreen::Actions::UsersIndex

Public Instance Methods

actions_matching(identity_params) click to toggle source
# File lib/sqreen/actions/users_index.rb, line 11
def actions_matching(identity_params)
  return [] unless @idx
  key = stringify_keys(identity_params)
  actions = @idx[key]
  actions || []
end
index(params, action) click to toggle source
# File lib/sqreen/actions/users_index.rb, line 18
def index(params, action)
  @idx ||= {}
  users = params['users']
  raise ::Sqreen::Exception, 'nil "users" param for block_user action' if users.nil?
  raise ::Sqreen::Exception, '"users" param must be an array' unless users.is_a? Array

  users.each do |u|
    @idx[u] ||= []
    @idx[u] << action
  end
end

Private Instance Methods

stringify_keys(hash) click to toggle source
# File lib/sqreen/actions/users_index.rb, line 32
def stringify_keys(hash)
  Hash[
    hash.map { |k, v| [k.to_s, v] }
  ]
end