Skip to content

Instantly share code, notes, and snippets.

View huyttq's full-sized avatar

Huy Thái huyttq

  • Perth, Australia
View GitHub Profile
@huyttq
huyttq / gist:1354244
Created November 10, 2011 06:14
Using yield to execute
def send_task
self.class.execute { self.prepare!; self }
end
def self.execute
begin
ActiveRecord::Base.connection.execute("LOCK TABLE tasks WRITE")
tasks = [*yield]
ensure
ActiveRecord::Base.connection.execute("UNLOCK TABLE")
@huyttq
huyttq / AASM_FactoryGirl.rb
Created November 10, 2011 02:37
Override initial state of AASM by using 'mocha' mock
TestObject.any_instance.stubs(:set_initial_state)