Class: Rule

Inherits:
Object
  • Object
show all
Defined in:
lib/turnstile/rule.rb

Overview

Rule class A simple to class to manipulate the array of rules

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rules) ⇒ Rule

Returns a new instance of Rule.



7
8
9
10
11
12
13
# File 'lib/turnstile/rule.rb', line 7

def initialize(rules)

  @action = rules[:action]
  @controller = rules[:controller]
  @allow = rules[:allow]
  @active = rules[:active]
end

Instance Attribute Details

#actionObject

Returns the value of attribute action.



5
6
7
# File 'lib/turnstile/rule.rb', line 5

def action
  @action
end

#activeObject

Returns the value of attribute active.



5
6
7
# File 'lib/turnstile/rule.rb', line 5

def active
  @active
end

#allowObject

Returns the value of attribute allow.



5
6
7
# File 'lib/turnstile/rule.rb', line 5

def allow
  @allow
end

#controllerObject

Returns the value of attribute controller.



5
6
7
# File 'lib/turnstile/rule.rb', line 5

def controller
  @controller
end

Instance Method Details

#allow_or_deny?Boolean

The current rule allows or denies some action?

Returns:

  • (Boolean)


16
17
18
# File 'lib/turnstile/rule.rb', line 16

def allow_or_deny?
  @allow == true ? :allow : :deny
end

#allows?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/turnstile/rule.rb', line 24

def allows?
  @allow ? true : false
end

#denies?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/turnstile/rule.rb', line 28

def denies?
  @allow ? false : true
end

#is_active?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/turnstile/rule.rb', line 20

def is_active?
  @active
end