Class: PolicyManager::Rule

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Rule

Returns a new instance of Rule.



10
11
12
13
14
15
16
17
18
# File 'lib/policy_manager/rule.rb', line 10

def initialize(opts={})
  self.name = opts[:name]
  self.blocking = opts[:blocking]
  self.validates_on = opts[:validates_on]
  self.if = opts[:if]
  self.on_reject = opts[:on_reject]
  self.on_accept = opts[:on_accept]
  self
end

Instance Attribute Details

#blockingObject

Returns the value of attribute blocking.



3
4
5
# File 'lib/policy_manager/rule.rb', line 3

def blocking
  @blocking
end

#ifObject

Returns the value of attribute if.



3
4
5
# File 'lib/policy_manager/rule.rb', line 3

def if
  @if
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/policy_manager/rule.rb', line 3

def name
  @name
end

#on_acceptObject

Returns the value of attribute on_accept.



3
4
5
# File 'lib/policy_manager/rule.rb', line 3

def on_accept
  @on_accept
end

#on_rejectObject

Returns the value of attribute on_reject.



3
4
5
# File 'lib/policy_manager/rule.rb', line 3

def on_reject
  @on_reject
end

#validates_onObject

Returns the value of attribute validates_on.



3
4
5
# File 'lib/policy_manager/rule.rb', line 3

def validates_on
  @validates_on
end

Instance Method Details

#on_accept_callbackObject



32
33
34
# File 'lib/policy_manager/rule.rb', line 32

def on_accept_callback
  @on_accept.call if @on_accept.is_a?(Proc)
end

#on_reject_callbackObject



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

def on_reject_callback
  @on_reject.call if @on_reject.is_a?(Proc)
end

#termsObject



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

def terms
  Term.where("rule =?", self.name)
end