Class: MasterView::HashSerializer

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

Overview

Serializer which simply outputs each fragment to a hash with the key representing the path and the value the string contents. You may specify this serializer as an option to the parser (:serializer => HashSerializer.new(output_hash)). It takes an empty hash as the single constructor parameter to which the contents will be output.

Instance Method Summary collapse

Constructor Details

#initialize(output_hash) ⇒ HashSerializer

Returns a new instance of HashSerializer.



227
228
229
# File 'lib/masterview/parser.rb', line 227

def initialize( output_hash )
  @output_hash = output_hash
end

Instance Method Details

#serialize(render_mode, tag) ⇒ Object



231
232
233
234
235
# File 'lib/masterview/parser.rb', line 231

def serialize(render_mode, tag)
  Log.debug { "adding to hash - outputing mode=#{render_mode.mode_type} to file=#{render_mode.output}" }
  @output_hash[ render_mode.output ] = tag.data.join
  true
end