summaryrefslogtreecommitdiff
path: root/lib/algorithm.rb
blob: 0e227d6ddf0c472aaa926fab5102d5325b40ce21 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
module OpenTox

  module Algorithm 

    def self.run algorithm, object, parameters={}
      bad_request_error "Cannot run '#{algorithm}' algorithm. Please provide an OpenTox::Algorithm." unless algorithm =~ /^OpenTox::Algorithm/
      klass,method = algorithm.split('.')
      parameters.empty? ?  Object.const_get(klass).send(method,object) : Object.const_get(klass).send(method,object, parameters)
    end

  end
end