Created
September 24, 2012 12:13
-
-
Save h-lame/3775651 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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