Skip to content

Instantly share code, notes, and snippets.

@ivanacostarubio
Created April 28, 2011 03:29
Show Gist options
  • Select an option

  • Save ivanacostarubio/945743 to your computer and use it in GitHub Desktop.

Select an option

Save ivanacostarubio/945743 to your computer and use it in GitHub Desktop.
# THE FOLLOWING 3 METHODS LOOK A LOT A LIKE
# A JUICY STEAK AWATING TO BE EATEN
# DUPLICATION SOON TO BE REMOVED
#
# MACHETE!
#
#
def create_lifeboat
q = RightAws::SqsGen2::Queue.create(@cue, "create_" + self.class.to_s.downcase, true)
q.send_message(self.attributes.to_json)
end
def update_lifeboat
q = RightAws::SqsGen2::Queue.create(@cue, "update_" + self.class.to_s.downcase, true)
q.send_message(self.attributes.to_json)
end
def destroy_lifeboat
q = RightAws::SqsGen2::Queue.create(@cue, "destroy_" + self.class.to_s.downcase, true)
q.send_message(self.attributes.to_json)
end
# They can be refactor to:
[:create, :update, :destroy ].each do |action|
define_method(action.to_s + "_lifeboat") do
q = RightAws::SqsGen2::Queue.create(@cue, action.to_s+"_"+ self.class.to_s.downcase, true)
q.send_message(self.attributes.to_json)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment