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 "cancan/model_adapters/active_record_adapter" | |
class CanCan::ModelAdapters::ActiveRecordAdapter | |
# disable the error when multiple conditions with scopes are used | |
def override_scope | |
return false | |
end | |
# convert where-clauses from relations into sql strings which will be merged by the cancan merge_conditions logic |
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 "cancan/model_adapters/active_record_adapter" | |
class CanCan::ModelAdapters::ActiveRecordAdapter | |
# use squeel's symbol-predicates to convert all joins into outer joins | |
# see https://github.com/ryanb/cancan/issues/374 | |
def clean_joins(joins_hash) | |
joins = [] | |
joins_hash.each do |name, nested| | |
name = name.outer if nested.is_a? Hash | |
joins << (nested.empty? ? name : {name => clean_joins(nested)}) |
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 "cancan/model_adapters/active_record_adapter" | |
class CanCan::ModelAdapters::ActiveRecordAdapter | |
def merge_conditions(sql, conditions_hash, behavior) | |
conditions_hash = Squeel::Nodes::Literal.new(conditions_hash) if conditions_hash.is_a? String | |
if conditions_hash.blank? | |
Squeel::Nodes::Literal.new(behavior ? true_sql : false_sql) | |
else | |
case sql |
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 'active_record' | |
class ReferencedModelA < ActiveRecord::Base; end | |
class ReferencedModelB < ActiveRecord::Base; end | |
class ReferencedModelC < ActiveRecord::Base; end | |
class ModelA < ActiveRecord::Base | |
has_many :referenced_model_a | |
end |
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
# encoding: UTF-8 | |
require "cancan/model_adapters/active_record_adapter" | |
class CanCan::Rule | |
def unmergeable? | |
false | |
end | |
end |
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
module Mhmr::DescendantsTracker | |
def descendants_and_self | |
[self].concat self.descendants | |
end | |
end | |
ActiveSupport::DescendantsTracker.send(:include,Mhmr::DescendantsTracker) | |
jruby: |
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
### ruby 1.9.3 + railsexpress patches + GC tuning + -march=native -O3 | |
time ruby script/rails r 'Post.count' | |
real 0m1.008s | |
user 0m0.820s | |
sys 0m0.180s | |
### jruby 1.7.2-dev 2012-12-12 + java 64bit 1.8.0-ea-b67 hotspot 25.0-b11 |
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
Compiled method (c2) 593 8 Test2::test1 (46 bytes) | |
total in heap [0x029af8c8,0x029b0184] = 2236 | |
relocation [0x029af99c,0x029af9b8] = 28 | |
main code [0x029af9c0,0x029afd00] = 832 | |
stub code [0x029afd00,0x029afd10] = 16 | |
oops [0x029afd10,0x029afd14] = 4 | |
metadata [0x029afd14,0x029afd18] = 4 | |
scopes data [0x029afd18,0x029afddc] = 196 | |
scopes pcs [0x029afddc,0x029b013c] = 864 | |
dependencies [0x029b013c,0x029b0140] = 4 |
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
import java.lang.reflect.Field; | |
import java.security.SecureRandom; | |
import sun.misc.Unsafe; | |
public class Test2 { | |
static final Unsafe unsafe; | |
static final long offsetA; | |
static final long offsetB; |
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/src/org/jruby/RubyBasicObject.java b/src/org/jruby/RubyBasicObject.java | |
index 2bb34e8..6de4bef 100644 | |
--- a/src/org/jruby/RubyBasicObject.java | |
+++ b/src/org/jruby/RubyBasicObject.java | |
@@ -38,6 +38,7 @@ | |
import java.util.Map; | |
import java.util.Set; | |
import java.util.concurrent.atomic.AtomicBoolean; | |
+import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; | |
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; |
OlderNewer