Skip to content

Instantly share code, notes, and snippets.

@adahl
Created March 23, 2010 09:17
Show Gist options
  • Save adahl/340983 to your computer and use it in GitHub Desktop.
Save adahl/340983 to your computer and use it in GitHub Desktop.
class UnwireController << Controller
def create <-- incoming message
IncomingMessageUnwire.create(params)
end
def update <-- delivery notification
OutgoingMessageUnwire.update(params)
end
end
class IncomingMessage << ActiveRecord
belongs_to:gateway_accounts
after_create :perform_action
def perform_action
# Perform action based on message (Newsletter, Contest, Game, etc.)
end
end
class IncomingMessageUnwire << IncomingMessage
def self.create
# Parse params and create incoming message
end
end
class OutgoingMessage << ActiveRecord
belongs_to:gateway_accounts
def send_message
# HTTP request
end
end
class OutgoingMessageUnwire << OutgoingMessage
def self.update(params)
# update message delivery status
end
after_create :send_message
def send_message
# marshal self into form data
super(form data)
end
end
class Gateway << ActiveRecord
has_many :gateway_accounts
# Contains information about each gateway
# Name
# Outgoing URL
# Callback URL
# Etc.
end
class GatewayAccount << ActiveRecord
belongs_to :gateway
has_many :incoming_messages
has_many :outgoing_messages
# An actual gateway account that a customer owns
# Identified by <shortcode, keyword>
def send_message(recipient, message, options = {})
# Somehow figure out which OutgoingMessage to create
# After creation the message will send itself.
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment