Skip to content

Instantly share code, notes, and snippets.

@conversionfoundry
Created November 3, 2009 20:04
Show Gist options
  • Save conversionfoundry/225376 to your computer and use it in GitHub Desktop.
Save conversionfoundry/225376 to your computer and use it in GitHub Desktop.
module Component::QuoteManager
class Configuration < Base
unloadable
# This is a hook that gets called whenever BreezeHQ is sending out a form response.
# The email still gets sent out, but this will let you grab the form responses
# when they're created.
# For sanity reasons, return message at the end.
def send_form_response(message)
QuoteProcessor.new(message.id).send_later(:process!)
message
end
end
end
module Component::QuoteManager
class QuoteProcessor < Struct.new(:quote_id)
# Called asynchronously by delayed_job
# so you can do all your SQL stuff in here
# (easier than running a separate rails app on the server)
def process!
# ...
end
def quote
@quote ||= Component::Form::Response.find(quote_id, :conditions => { :site_id => site_id })
end
def quote_data
@quote_data ||= quote.values
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment