Class: Pipeline::Model::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/etl-pipeline.rb

Instance Method Summary collapse

Instance Method Details

#attributesObject



43
44
45
46
47
48
49
# File 'lib/etl-pipeline.rb', line 43

def attributes
  attributes_hash = Hash.new
  self.instance_variables.each do |attr|
    attributes_hash.store(attr[1..-1].to_sym, instance_eval(attr.to_s))
  end
  attributes_hash
end

#formatObject



51
52
# File 'lib/etl-pipeline.rb', line 51

def format
end

#formatted_attributesObject



54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/etl-pipeline.rb', line 54

def formatted_attributes
  attr_hash = attributes
  attr_hash.each do |k,v|
    begin
      attr_hash[k] = send("format_#{k}".to_sym, v)
    rescue NoMethodError => e
      # No formatter defined, use passed value as formatted value
      attr_hash[k] = v.to_s
    end
  end

  attr_hash
end