module Brief module Handlers class Base attr_accessor :element, :prepared def initialize(element) @element = element end def method_missing meth, *args, &block if element.respond_to?(meth) return element.send(meth, *args, &block) end super end def content element.content end def document get_manager.try :document end def document_settings document.try(:settings) end def get_manager &block if block_given? @get_manager = block end @get_manager && @get_manager.call() end def parent &block if block_given? @find_parent_block = block end @find_parent_block && @find_parent_block.call(element.parent_id) end # Your handler should implement this method, the goal is to transform the # element we are passed into an object that is suitable for whatever integration # you have planned for it. For example, preparing the necessary attributes for # a submission to github issues or milestones def prepare! @prepared ||= begin element end end # Do whatever you want to do with the prepared element def handle! prepare! end end end end