Skip to content

Instantly share code, notes, and snippets.

@h-lame
Created September 24, 2012 12:13
Show Gist options
  • Save h-lame/3775651 to your computer and use it in GitHub Desktop.
Save h-lame/3775651 to your computer and use it in GitHub Desktop.
module TicketProcessing
class TicketHTMLGenerator
def initialize(ticket)
@ticket = ticket
end
def generate!
renderer.render(context)
end
def context
{
template: 'orders/generated_ticket',
locals: {
ticket: @ticket,
activity: @ticket.activity,
user: @ticket.user
}
}
end
def renderer
# NOTE: this might not include our custom helpers
# If it doesn't (and we need/want them) we might have to do something
# along the lines of: http://amberbit.com/blog/render-views-partials-outside-controllers-rails-3
@renderer ||=
ActionView::Base.new(ActionView::LookupContext.new(ActionController::Base.view_paths))
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment