Class: Opto::Resolvers::Condition::HashCond
- Inherits:
-
Object
- Object
- Opto::Resolvers::Condition::HashCond
- Defined in:
- lib/opto/resolvers/condition.rb
Instance Attribute Summary collapse
-
#condition ⇒ Object
readonly
Returns the value of attribute condition.
-
#group ⇒ Object
readonly
Returns the value of attribute group.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
- #else? ⇒ Boolean
-
#initialize(group, options = {}) ⇒ HashCond
constructor
A new instance of HashCond.
- #true? ⇒ Boolean
Constructor Details
#initialize(group, options = {}) ⇒ HashCond
Returns a new instance of HashCond.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/opto/resolvers/condition.rb', line 39 def initialize(group, ={}) @group = group if .has_key?(:else) @result = [:else] @else = true elsif .has_key?(:if) || .has_key?(:elsif) @condition = [:if] || [:elsif] if .has_key?(:then) @result = [:then] else raise ArgumentError, "Invalid condition definition: #{.inspect} (no 'then')" end @else = false else raise ArgumentError, "Invalid condition definition: #{.inspect} (no 'if', 'elsif' or 'else')" end end |
Instance Attribute Details
#condition ⇒ Object (readonly)
Returns the value of attribute condition.
35 36 37 |
# File 'lib/opto/resolvers/condition.rb', line 35 def condition @condition end |
#group ⇒ Object (readonly)
Returns the value of attribute group.
37 38 39 |
# File 'lib/opto/resolvers/condition.rb', line 37 def group @group end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
36 37 38 |
# File 'lib/opto/resolvers/condition.rb', line 36 def result @result end |
Instance Method Details
#else? ⇒ Boolean
57 58 59 |
# File 'lib/opto/resolvers/condition.rb', line 57 def else? @else end |
#true? ⇒ Boolean
61 62 63 64 65 |
# File 'lib/opto/resolvers/condition.rb', line 61 def true? return true if else? return true if group.all_true?(condition) false end |