Class: Fabulator::Core::Actions::Catch

Inherits:
Action
  • Object
show all
Defined in:
lib/fabulator/core/actions/choose.rb

Instance Method Summary collapse

Instance Method Details

#run(context, autovivify = false) ⇒ Object



91
92
93
94
95
96
# File 'lib/fabulator/core/actions/choose.rb', line 91

def run(context, autovivify = false)
  @context.with(context) do |ctx|
    ctx.set_var(self.as, context) if self.as
    return self.run_actions(context)
  end
end

#run_test(context) ⇒ Object



81
82
83
84
85
86
87
88
89
# File 'lib/fabulator/core/actions/choose.rb', line 81

def run_test(context)
  return true if @test.nil?
  @context.with(context) do |ctx|
    ctx.set_var(@as, context) if @as
    result = self.test(context).collect{ |a| !!a.value }
    return false if result.nil? || result.empty? || !result.include?(true)
    return true
  end
end