This file contains 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
diff --git a/activerecord/lib/active_record/named_scope.rb b/activerecord/lib/active_record/named_scope.rb | |
index 83043c2..8c2507e 100644 | |
--- a/activerecord/lib/active_record/named_scope.rb | |
+++ b/activerecord/lib/active_record/named_scope.rb | |
@@ -93,7 +93,11 @@ module ActiveRecord | |
end | |
(class << self; self end).instance_eval do | |
define_method name do |*args| | |
- scopes[name].call(self, *args) | |
+ if scoped? :find |
This file contains 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
gem 'RubyInline' | |
require 'inline' | |
class Test | |
inline do |builder| | |
builder.include "<time.h>" | |
builder.c_raw <<-SRC, :arity => 1 | |
VALUE dummy(VALUE self, VALUE arg){ | |
VALUE ret = rb_funcall(self, rb_intern("binding"), 0); | |
return ret; |
This file contains 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 'benchmark/ips' | |
require 'set' | |
set = Set[:$or, :$and, :$nor] | |
array = %i($or $and $nor) | |
Benchmark.ips do |x| | |
x.config(:time => 10, :warmup => 2) |
This file contains 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
if Rails::VERSION::MAJOR > 4 | |
raise "This patch is obsolete and should be removed" | |
end | |
class Time | |
def compare_with_coercion(other) | |
# we're avoiding Time#to_datetime and Time#to_time because they're expensive | |
if other.class == Time | |
compare_without_coercion(other) | |
elsif other.is_a?(Time) |
This file contains 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
event = fn | |
{:startElement, _, 'Contents', _, _}, _, state -> | |
put_in(state[:current], %{}) | |
{:startElement, _, _name, _, _}, _, state -> | |
put_in(state[:value], "") | |
{:characters, data}, _, state -> | |
update_in(state[:value], &(to_string(data) <> &1)) | |
{:endElement, _, 'Contents', _}, _, state -> |
NewerOlder