web/app/helpers/settings/runtimes_helper.rb
author Marcel Hlopko <marcel.hlopko@gmail.com>
Wed, 26 Jun 2013 00:05:56 +0200
changeset 111 28dccacb2bc1
parent 106 eac4098d544d
child 236 2565b32e93b3
permissions -rw-r--r--
fixes

module Settings::RuntimesHelper

  def all_runtimes
    Runtime.all
  end

  def all_runtimes_options
    all_runtimes.map { |r| [r.name, r.id.to_s] }
  end

  def all_dates_when_performed(runtimeOrRuntimes)
    if runtimeOrRuntimes.kind_of?(BenchmarkConfiguration)
      runtimeOrRuntimes.all_dates_when_performed
    elsif runtimeOrRuntimes.kind_of?(Enumerable) || runtimeOrRuntimes.kind_of?(ActiveRecord::Relation)
      SortedSet.new(runtimeOrRuntimes.map(&:all_dates_when_performed).flatten).to_a
    else
      raise "Unexpected argument type: #{runtimeOrRuntimes.class}"
    end
  end
  
end