Class: InterceptBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/intercept_builder.rb

Class Method Summary collapse

Class Method Details

.build_worker(callback, description) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/intercept_builder.rb', line 2

def self.build_worker(callback, description)
  interceptor_map = {}
  decorator_map = {}

  description[:interception].each do |unit|
    strategy = Intercept::StrategyBuilder.from_hash(unit[:strategy])

    unit[:fields].each do |field|
      interceptor_map[field] = strategy
    end
  end

  description[:decoration].each do |unit|
    decorator = Intercept::DecoratorBuilder.from_hash(unit[:decorator])

    unit[:fields].each do |field|
      decorator_map[field] = decorator
    end
  end

  Intercept::Worker.new(callback, interceptor_map, decorator_map)
end