Aaron Patterson tenderlove

View gist:7573807
1 2 3 4 5 6 7 8 9 10
require 'benchmark'
 
TIMES = 10_000_000
 
module M
X = ''
module N
module A
module B
def self.x
View omg.diff
1 2 3 4 5 6 7 8 9 10
diff --git a/activesupport/lib/active_support/notifications.rb b/activesupport/lib/active_support/notifications.rb
index b32aa75..7a96c66 100644
--- a/activesupport/lib/active_support/notifications.rb
+++ b/activesupport/lib/active_support/notifications.rb
@@ -178,7 +178,7 @@ module ActiveSupport
end
def instrumenter
- InstrumentationRegistry.instrumenter_for(notifier)
+ InstrumentationRegistry.instance.instrumenter_for(notifier)
View delegate.rb
1 2 3 4 5 6 7 8 9 10
#!/usr/bin/env ruby
 
class Module
private
 
def delegate(*args)
_define_delegators(caller.first, args, false)
end
 
def delegate_maybe(*args)
View cachebust.diff
1 2 3 4 5 6 7 8 9 10
diff --git a/probes.d b/probes.d
index dd7a7bf..e077bd8 100644
--- a/probes.d
+++ b/probes.d
@@ -214,6 +214,16 @@ provider ruby {
Fired at the end of a sweep phase.
*/
probe gc__sweep__end();
+
+ /*
View test.rb
1 2 3 4 5 6 7 8 9 10
require 'active_record'
 
ActiveRecord::Base.establish_connection 'sqlite3:///:memory:'
ActiveRecord::Base.connection.instance_eval do
create_table :items
create_table :events do |t|
t.belongs_to :item
end
create_table :event_people do |t|
t.belongs_to :event
View omg.diff
1 2 3 4 5 6 7 8 9 10
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md
index 08803f8..8ee38fc 100644
--- a/activerecord/CHANGELOG.md
+++ b/activerecord/CHANGELOG.md
@@ -1,3 +1,6 @@
+* `has_and_belongs_to_many` is now transparently implemented in terms of
+ `has_many :through`. Behavior should remain the same, if not, it is a bug.
+
* `create_savepoint`, `rollback_to_savepoint` and `release_savepoint` accept
a savepoint name.
View habtm.patch
1 2 3 4 5 6 7 8 9 10
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb
index 33cbafc..d68fb33 100644
--- a/activerecord/lib/active_record/associations.rb
+++ b/activerecord/lib/active_record/associations.rb
@@ -1560,8 +1560,86 @@ module ActiveRecord
# has_and_belongs_to_many :categories, join_table: "prods_cats"
# has_and_belongs_to_many :categories, -> { readonly }
def has_and_belongs_to_many(name, scope = nil, options = {}, &extension)
- reflection = Builder::HasAndBelongsToMany.build(self, name, scope, options, &extension)
- Reflection.add_reflection self, name, reflection
View pull.rb
1 2 3 4 5 6 7 8 9 10
require 'psych'
require 'thread'
 
class PullParser
def initialize io
@queue = SizedQueue.new 10
parser = Psych::Parser.new self
@thread = Thread.new {
begin
parser.parse io
View wat.diff
1 2 3 4 5 6 7 8 9 10
diff --git a/activerecord/test/cases/associations/has_many_through_associations_test.rb b/activerecord/test/cases/associations/has_many_through_associations_test.rb
index c0e80c5..5299e4e 100644
--- a/activerecord/test/cases/associations/has_many_through_associations_test.rb
+++ b/activerecord/test/cases/associations/has_many_through_associations_test.rb
@@ -37,6 +37,13 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase
Reader.create :person_id => 0, :post_id => 0
end
+ def test_preload_sti_rhs_class
+ developers = Developer.includes(:firms).all.to_a
View boo.rb
1 2 3 4 5 6 7 8 9 10
require 'active_record'
 
class ActiveRecord::Base
establish_connection 'sqlite3:///:memory:'
connection.create_table :rights do |t|
t.string :type
end
end
 
class Right < ActiveRecord::Base; end
Something went wrong with that request. Please try again.