Class: Eatr::TransformationSet

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/eatr/transformation_set.rb

Instance Method Summary collapse

Constructor Details

#initialize(transformations) ⇒ TransformationSet

Returns a new instance of TransformationSet.



5
6
7
# File 'lib/eatr/transformation_set.rb', line 5

def initialize(transformations)
  @transformations = transformations
end

Instance Method Details

#eachObject



9
10
11
12
13
# File 'lib/eatr/transformation_set.rb', line 9

def each
  to_a.each do |t|
    yield t
  end
end

#to_aObject



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/eatr/transformation_set.rb', line 15

def to_a
  @transformations.map do |t|
    const = Object.const_get(t.fetch('class'))

    if t['args']
      const.new(t['args'])
    else
      const.new
    end
  end
end