Class: SimpleEtl::Source::Row

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_etl/source/row.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Row

Returns a new instance of Row.



6
7
8
# File 'lib/simple_etl/source/row.rb', line 6

def initialize attributes = {}
  @attributes = attributes
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/simple_etl/source/row.rb', line 10

def method_missing name, *args, &block
  md = name.to_s.match /^(\w+)(=)?$/
  if md && attributes.has_key?(md[1].to_sym)
    field = md[1].to_sym
    md[2] && (attributes[field] = args.first) || attributes[field]
  else
    super
  end
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



4
5
6
# File 'lib/simple_etl/source/row.rb', line 4

def attributes
  @attributes
end