Class: ActionGuard::Syntax

Inherits:
Object
  • Object
show all
Defined in:
lib/action-guard/syntax.rb

Instance Method Summary collapse

Constructor Details

#initialize(action_guard) ⇒ Syntax

Returns a new instance of Syntax.



3
4
5
# File 'lib/action-guard/syntax.rb', line 3

def initialize(action_guard)
  @guard = action_guard
end

Instance Method Details

#allow(path, options = {}, &block) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/action-guard/syntax.rb', line 9

def allow(path, options={}, &block)
  if options.has_key? :at_least
    @guard.leveled_rule(path, options[:at_least], options[:at_most], &block)
  elsif options.has_key? :only_by
    @guard.exact_role_rule(path, options[:only_by])
  else
    @guard.allow_rule(path, &block)
  end
end

#role(role_value, role_level) ⇒ Object



6
7
8
# File 'lib/action-guard/syntax.rb', line 6

def role(role_value, role_level)
  @guard.define_role(role_value, role_level)
end