Class: Alephant::Writer

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Writer

Returns a new instance of Writer.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/alephant/models/writer.rb', line 7

def initialize(opts)
  @renderer_id =
    opts[:renderer_id]
  @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]
end

Instance Attribute Details

#cacheObject (readonly)

Returns the value of attribute cache.



5
6
7
# File 'lib/alephant/models/writer.rb', line 5

def cache
  @cache
end

#mapperObject (readonly)

Returns the value of attribute mapper.



5
6
7
# File 'lib/alephant/models/writer.rb', line 5

def mapper
  @mapper
end

Instance Method Details

#write(data, version = nil) ⇒ Object



22
23
24
25
26
# File 'lib/alephant/models/writer.rb', line 22

def write(data, version = nil)
  mapper.generate(data).each do |id, r|
    store(id, r.render, data[:options], version)
  end
end