Module: Pest::DataSet::ClassMethods

Defined in:
lib/pest/data_set.rb

Instance Method Summary collapse

Instance Method Details

#from(data_source) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/pest/data_set.rb', line 31

def from(data_source)
  # Try to translate the data source directly
  if translator_method = translators[data_source.class]
    send(translator_method, data_source)

  # Try to translate via hash
  else
    begin
      hash_data = data_source.to_hash
    rescue NoMethodError
      raise "Unrecognized data source type"
    end
    
    if hash_data and translators.has_key?(hash_data.class)
      from(data_source.to_hash)
    end
  end
end

#from_file(*args) ⇒ Object

Raises:

  • (NotImplementedError)


54
55
56
# File 'lib/pest/data_set.rb', line 54

def from_file(*args)
  raise NotImplementedError
end

#from_hash(*args) ⇒ Object

Raises:

  • (NotImplementedError)


58
59
60
# File 'lib/pest/data_set.rb', line 58

def from_hash(*args)
  raise NotImplementedError
end

#translators(*args) ⇒ Object

Raises:

  • (NotImplementedError)


50
51
52
# File 'lib/pest/data_set.rb', line 50

def translators(*args)
  raise NotImplementedError
end