Sha256: ce2a17a8ace41e08e090cd31f065b1316ba09c433c4c6ae8c027dfb5da4007fc
Contents?: true
Size: 1.08 KB
Versions: 2
Compression:
Stored size: 1.08 KB
Contents
require 'crimp' module Alephant class Writer attr_reader :mapper, :cache 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 def write(data, version = nil) mapper.generate(data).each do |id, r| store(id, r.render, data[:options], version) end end private def store(id, content, options, version) location = location_for( id, Crimp.signature(options), version ) cache.put(location, content) lookup(id).write(options, location) end def lookup(component_id) Lookup.create(@lookup_table_name, component_id) end def location_for(component_id, options_hash, version = nil) base_name = "#{@renderer_id}/#{component_id}/#{options_hash}" version ? "#{base_name}/#{version}" : base_name end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
alephant-0.1.4.1-java | lib/alephant/models/writer.rb |
alephant-0.1.4-java | lib/alephant/models/writer.rb |