Module: Resque::Plugins::DataWarehouse::Fact

Defined in:
lib/resque/plugins/data_warehouse/fact.rb

Class Method Summary collapse

Class Method Details

.find(type, values) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/resque/plugins/data_warehouse/fact.rb', line 6

def self.find(type, values)
  klass = "Facts::#{type}Fact".constantize
  fact = klass.send(:find, values["id"]) rescue nil
  fact = klass.new if fact.nil?
  fact.id = values["id"]
  values.delete("id")
  values.delete_if{|key,value| !fact.attribute_names.include?(key)}
  fact.attributes = values
  fact
end