An even more flexible approach which allows for easy customization/
extension, using registration of "result handlers" called in
succession in a sort of chain pattern.

    def do_tag(context, *args)
      result_output = ""
      args.each_with_index do |arg_item, index|
          ...
          sub_result_output, return_context = result_handler
(result_output, context, arg_result)
          ...
      end
      ...
    end

  # register result handlers
    # you can add more runtime if needed
    result_handlers = [handle_res_1, handle_res_2]

    def result_handler(result_output, context, arg_result)
      result_handlers.each do |handler|
        result_output, context = handler.call(result_output, context,
arg_result)
      end
      return result_output, context
    end

    # always return an output and a context (to be added to parent
context)
    # default handler only supplies comma functionality
    def handle_res_1(result_output, context, arg_result)
      if context[:separator]
        result_output, context = do_separator(result_output, context,
arg_result)
      end
      if
        ...
      end
      return result_output, context
    end

    # you can define your own custom result handlers to handle new
requirements
    def handle_res_2(result_output, context, arg_result)
      ...
      return result_output, context
    end

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/hobousers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to