Class: Checken::Rule
- Inherits:
-
Object
- Object
- Checken::Rule
- Defined in:
- lib/checken/rule.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#required_object_types ⇒ Object
readonly
Returns the value of attribute required_object_types.
Instance Method Summary collapse
-
#initialize(key, &block) ⇒ Rule
constructor
A new instance of Rule.
-
#satisfied?(rule_execution) ⇒ Boolean
Are we satisifed that this rule’s condition is true?.
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
#key ⇒ Object (readonly)
Returns the value of attribute key.
4 5 6 |
# File 'lib/checken/rule.rb', line 4 def key @key end |
#required_object_types ⇒ Object (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?
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 |