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 'invalid_length_error' | |
module ActiveModel | |
class Errors | |
def normalize_message(attribute, message, options) | |
custom_message = options[:message] || message || :invalid | |
if custom_meesage.respond_to?(:call) | |
custom_message.call(attribute, options) | |
elsif custom_message.is_a?(Symbol) |
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 Interface | |
def ===(obj) | |
self.instance_methods.all?{|m| obj.respond_to?(m)} | |
end | |
end | |
module IService | |
extend Interface |
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 Ad | |
def self.last_unverified | |
self.unverified_ads.last | |
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
def glassy_link(txt, url) | |
link_to txt, url, :class => :glassy | |
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
def format_date(date) | |
date.to_formatted_s(:long) | |
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
SomeFeature: | |
ERROR test_something (0.42s) | |
SystemStackError: stack level too deep | |
/home/rupert/.rvm/rubies/ruby-1.9.2-p180-fastrequire/lib/ruby/1.9.1/prettyprint.rb:206 |
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
ruby-1.9.2-p180-fastrequire :001 > f = Fiber.new do | |
ruby-1.9.2-p180-fastrequire :002 > @something ||= begin | |
ruby-1.9.2-p180-fastrequire :003 > Fiber.yield # external query | |
ruby-1.9.2-p180-fastrequire :004?> 2 | |
ruby-1.9.2-p180-fastrequire :005?> end | |
ruby-1.9.2-p180-fastrequire :006?> end | |
=> #<Fiber:0x000000028d45a8> | |
ruby-1.9.2-p180-fastrequire :007 > f.resume | |
=> nil | |
ruby-1.9.2-p180-fastrequire :008 > puts @something.inspect |
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 'rubygems' | |
require 'gelf' | |
n = GELF::Notifier.new("localhost", 12201) | |
index = 0 | |
t = Time.now | |
File.open("production.log") do |f| | |
f.each_line do |line| | |
n.info(line) |
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 SessionFactory | |
def next(options) | |
Capybara::Session.new(options[:driver], Bbq.app) | |
end | |
end | |
class PooledSessionFactory | |
attr_accessor :idle, :taken | |
def initialize(session_factory) |
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
(bob & cindy).is_ok? | |
(bob & cindy).receive_message do |user, message| | |
end | |
TestUser === bob.class | |
TestUserGroup === (bob & cindy).class |