29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/authoritah.rb', line 29
def apply_declaration(perm_type, action_identifier, args)
options = args.
args.each {|a| options[a] = nil}
actions = options.delete(action_identifier)
on_reject = options.delete(:on_reject) || :render_404
raise ":on_reject must be a symbol or a Proc" unless on_reject.is_a?(Symbol) || on_reject.is_a?(Proc)
check_role_selectors(options)
role_method = options.to_a.first[0]
role_predicate = options.to_a.first[1]
controller_permissions << {
:type => perm_type,
:role_method => role_method,
:role_predicate => role_predicate,
:actions => actions ? Array(actions) : nil,
:on_reject => on_reject
}
end
|