class Opto::Resolvers::Condition::HashCond

Attributes

condition[R]
group[R]
result[R]

Public Class Methods

new(group, options={}) click to toggle source
# File lib/opto/resolvers/condition.rb, line 39
def initialize(group, options={})
  @group = group
  if options.has_key?(:else)
    @result = options[:else]
    @else = true
  elsif options.has_key?(:if) || options.has_key?(:elsif)
    @condition = options[:if] || options[:elsif]
    if options.has_key?(:then)
      @result = options[:then]
    else
      raise ArgumentError, "Invalid condition definition: #{options.inspect} (no 'then')"
    end
    @else = false
  else
    raise ArgumentError, "Invalid condition definition: #{options.inspect} (no 'if', 'elsif' or 'else')"
  end
end

Public Instance Methods

else?() click to toggle source
# File lib/opto/resolvers/condition.rb, line 57
def else?
  @else
end
true?() click to toggle source
# File lib/opto/resolvers/condition.rb, line 61
def true?
  return true if else?
  return true if group.all_true?(condition)
  false
end