Class: Burlap::DefaultResolver
Instance Method Summary collapse
-
#convert_to_native(obj) ⇒ Object
obj is expected to respond to #name, #value and #children (eg, an instance of BaseTag).
- #mappings(*names, &block) ⇒ Object
Instance Method Details
#convert_to_native(obj) ⇒ Object
obj is expected to respond to #name, #value and #children (eg, an instance of BaseTag)
22 23 24 25 |
# File 'lib/burlap/default_resolver.rb', line 22 def convert_to_native obj mapping = mappings[obj.name] || raise(Error, "couldn't handle tag #{obj.name.inspect}") mapping.call(obj) end |
#mappings(*names, &block) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/burlap/default_resolver.rb', line 6 def mappings(*names, &block) # Default's to a hash @mappings ||= {} # return early, return often. Or is that release? return @mappings if names.empty? # Set said block for each name names.each do |name| @mappings[name] = proc(&block) end @mappings end |