Class: Checken::Rule

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, &block) ⇒ Rule

Returns a new instance of Rule.



7
8
9
10
11
# File 'lib/checken/rule.rb', line 7

def initialize(key, &block)
  @key = key
  @block = block
  @required_object_types = []
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



4
5
6
# File 'lib/checken/rule.rb', line 4

def key
  @key
end

#required_object_typesObject (readonly)

Returns the value of attribute required_object_types.



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

def required_object_types
  @required_object_types
end

Instance Method Details

#satisfied?(rule_execution) ⇒ Boolean

Are we satisifed that this rule’s condition is true?

Parameters:

Returns:

  • (Boolean)


17
18
19
# File 'lib/checken/rule.rb', line 17

def satisfied?(rule_execution)
  !!@block.call(rule_execution.user, rule_execution.object, rule_execution)
end