8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/charcoal/controller_filter.rb', line 8
def allow(filter, &block)
action = "allow_#{filter}"
define_method action do |*args|
options = args.last.is_a?(Hash) ? args.pop : {}
options.assert_valid_keys(:only, :except, :if, :unless)
methods = args.map(&:to_sym)
methods = [:all] if methods.empty?
directive = if options[:unless]
lambda { |c| !parse_directive(options[:unless]).call(c) }
else
parse_directive(options[:if] || true)
end
methods.each do |method|
instance_exec(method, directive, &block)
end
end
end
|