Class: Alephant::Publisher::Writer

Inherits:
Object
  • Object
show all
Defined in:
lib/alephant/publisher/writer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Writer

Returns a new instance of Writer.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/alephant/publisher/writer.rb', line 14

def initialize(opts)
  @cache = Cache.new(
    opts[:s3_bucket_id],
    opts[:s3_object_path]
  )

  @mapper = RenderMapper.new(
    opts[:renderer_id],
    opts[:view_path]
  )

  @lookup_table_name = opts[:lookup_table_name]

  @renderer_id = opts[:renderer_id]

  @write_opts = {
    :sequencer_opts => {
      :table_name => opts[:sequencer_table_name],
      :id_path    => opts[:sequence_id_path]
    },
    :msg_vary_path => opts[:msg_vary_id_path],
    :renderer_id => opts[:renderer_id]
  }
end

Instance Attribute Details

#cacheObject (readonly)

Returns the value of attribute cache.



12
13
14
# File 'lib/alephant/publisher/writer.rb', line 12

def cache
  @cache
end

#mapperObject (readonly)

Returns the value of attribute mapper.



12
13
14
# File 'lib/alephant/publisher/writer.rb', line 12

def mapper
  @mapper
end

Instance Method Details

#write(msg) ⇒ Object



39
40
41
42
43
44
45
46
47
# File 'lib/alephant/publisher/writer.rb', line 39

def write(msg)
  write_op = WriteOperation.new(msg, @write_opts)

  write_op.batch_sequencer.sequence(msg) do |msg|
    mapper.generate(write_op.data).each do |component_id, renderer|
      write_component(write_op, component_id, renderer)
    end
  end
end