Skip to content

Instantly share code, notes, and snippets.

View methodmissing's full-sized avatar

Lourens Naudé methodmissing

View GitHub Profile
diff --git a/lib/query_memcached.rb b/lib/query_memcached.rb
index c911388..715c47d 100644
--- a/lib/query_memcached.rb
+++ b/lib/query_memcached.rb
@@ -88,6 +88,7 @@ module ActiveRecord
end
+if ActiveRecord::ConnectionAdapters.const_defined?( 'PostgreSQLAdapter' )
class PostgreSQLAdapter < AbstractAdapter
# Returns the path to the rails/init.rb file for the given extension,
# or nil if no gem provides it.
def init_path_for_extension(extension)
return if extension.blank?
return unless spec = Gem.searcher.find(extension.to_s)
returning File.join(spec.full_gem_path, 'rails', 'init.rb') do |path|
return unless File.file?(path)
end
end
assert_raise(FiberError){
Fiber.yield
}
ExceptionNotifier.exception_recipients = %w(you@yourdomain.com)
ExceptionNotifier.class_eval do
remove_method :template_root
ExceptionNotifier.template_root = "#{RAILS_ROOT}/vendor/plugins/exception_notification/lib/../views"
end
# Delivers a TMail::Mail object. By default, it delivers the cached mail
# object (from the <tt>create!</tt> method). If no cached mail object exists, and
# no alternate has been given as the parameter, this will fail.
def deliver!(mail = @mail)
raise "no mail object available for delivery!" unless mail
unless logger.nil?
logger.info "Sent mail to #{Array(recipients).join(', ')}"
logger.debug "\n#{mail.encoded}"
end
class RouteFilter
class << self
def routes
ActionController::Routing::Routes.routes
end
def controllers
::Object.subclasses_of( ::ActionController::Base )
module ActiveResource
class Base
protected
alias :original_create :create
def create( attributes = {} )
self.attributes = attributes
original_create
class Class
def publicize_methods!
hidden_methods = self.private_instance_methods + self.protected_instance_methods
self.class_eval { public *hidden_methods }
end
end
require 'rubygems'
require 'activesupport'
z = returning( "" ) do |html|
html += "stuff"
html += "more stuff" if true
end
z = returning( [] ) do |html|
html << "stuff"
#abstract/database_statements.rb
# Returns the last auto-generated ID from the affected table.
def insert_sql(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil)
execute(sql, name)
id_value
end
#mysql_adapter.rb