This file contains hidden or 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
require "eventmachine" | |
require "mailfactory" | |
mail = MailFactory.new | |
mail.to = '[email protected]' | |
mail.from = '[email protected]' | |
mail.subject = 'hi!' | |
mail.text = 'hello world' | |
mail.html = '<h1>hello world</h1>' | |
binding.pry() |
This file contains hidden or 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 AfterCommitPatch | |
def transaction(options = {}) | |
rolled_back = false | |
begin | |
super | |
rescue ActiveRecord::Rollback => e | |
rolled_back = true | |
end | |
invoke_commit_objects unless rolled_back | |
end |
This file contains hidden or 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
class User < ActiveRecord::Base | |
attr_accessible :name | |
attr_accessible :options, :name | |
serialize :options | |
def options | |
self[:options] ||= {} | |
end | |
end |
This file contains hidden or 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
class User < ActiveRecord::Base | |
attr_accessible :name | |
after_commit :wow, :on => :create, :unless => :no_commit | |
attr_accessor :no_commit | |
def wow | |
puts "Calling wow" | |
self.no_commit = true | |
self.save | |
puts "Done called wow" |
This file contains hidden or 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
class SaveFromAfterCommitBlockTest < ActiveRecord::TestCase | |
class TopicWithSaveInCallback < ActiveRecord::Base | |
self.table_name = :topics | |
after_commit :cache_topic, :on => :create | |
def cache_topic | |
puts "******************* calling this stuff again #{cached.inspect}" | |
unless cached | |
self.cached = true | |
self.save |
This file contains hidden or 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
#!/usr/bin/env bash | |
apt-add-repository -y ppa:brightbox/ruby-ng | |
apt-get -y update | |
apt-get -y install build-essential | |
apt-get -y install zlib1g-dev libssl-dev libreadline-gplv2-dev libyaml-dev | |
apt-get -y install ruby1.9.3 ruby-switch | |
ruby-switch --set ruby1.9.1 | |
gem install chef ruby-shadow --no-ri --no-rdoc |
This file contains hidden or 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
#!/usr/bin/env bash | |
apt-add-repository -y ppa:brightbox/ruby-ng | |
apt-get -y update | |
apt-get -y install build-essential | |
apt-get -y install zlib1g-dev libssl-dev libreadline-gplv2-dev libyaml-dev | |
apt-get -y install ruby1.9.3 ruby-switch | |
ruby-switch --set ruby1.9.1 | |
gem install chef ruby-shadow --no-ri --no-rdoc |
This file contains hidden or 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
class Object | |
def should_chain_receive(*args,&block) | |
current_object = self | |
args[0..-2].each do |argument| | |
temp = Object.new() | |
current_object.should_receive(argument).and_return(temp) | |
current_object = temp | |
end | |
result = yield | |
current_object.should_receive(args.last).and_return result |
This file contains hidden or 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
class Object | |
def should_chain_receive(*args,&block) | |
if block_given? | |
ChainReceive.new(self,args,block) | |
else | |
ChainReceive.new(self,args) | |
end | |
end | |
end |
This file contains hidden or 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
#!c:\ruby\bin\rubyw.exe | |
require 'mpgapi4r.rb' #path to mpgapi4r.rb | |
p = ReqMod::Purchase.new | |
p.order_id = "prodtest2" | |
p.cust_id = "test" | |
p.amount = "0.00" | |
p.crypt_type = "7" | |
p.pan = "4514011602554956" |