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
class Foo | |
def bar(*args) | |
attribute(:bar, *args) | |
end | |
def attribute(name) | |
puts name | |
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 IdempotentCounterCache | |
module BuilderExtension | |
def add_counter_cache_callbacks(reflection) | |
super | |
cache_column = reflection.counter_cache_column | |
foreign_key = reflection.foreign_key | |
# This skip_callback do not work... may be related to https://github.com/rails/rails/issues/12571 | |
# model.skip_callback(:destroy, :before, "belongs_to_counter_cache_before_destroy_for_#{name}") |
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
$ bundle exec ruby per_thread_registry_benchmark.rb | |
Calculating ------------------------------------- | |
thread-safe 25.176k i/100ms | |
thread-unsafe 30.069k i/100ms | |
------------------------------------------------- | |
thread-safe 1.480M (± 6.5%) i/s - 7.377M | |
thread-unsafe 2.480M (± 7.2%) i/s - 12.328M |
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
Calculating ------------------------------------- | |
thread-safe 72.674k i/100ms | |
------------------------------------------------- | |
thread-safe 2.128M (± 5.8%) i/s - 10.610M | |
Calculating ------------------------------------- | |
thread-unsafe 109.385k i/100ms | |
------------------------------------------------- | |
thread-unsafe 5.545M (± 7.9%) i/s - 27.565M |
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 'active_support/cache' | |
require 'memcached' | |
require 'active_support/cache/memcached_store' | |
require 'active_support/cache/dalli_store' | |
$dalli = ActiveSupport::Cache::DalliStore.new('127.0.0.1:11211') | |
$memcached = ActiveSupport::Cache::MemcachedStore.new('127.0.0.1:11211') | |
KEY = 'somekey' |
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
begin | |
require 'bundler/inline' | |
rescue LoadError => e | |
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler' | |
raise e | |
end | |
gemfile(true) do | |
source 'https://rubygems.org' | |
# Activate the gem you are reporting the issue against. |
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
class Recette < AR::Base | |
has_many :ingredients | |
end | |
class Ingredient < AR::Base | |
belongs_to :recette | |
has_one :ingedient_type | |
end | |
class IngredientType < AR::Base |
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
class A: | |
def open(self): | |
# code avant | |
self._open(self) | |
# code après | |
class B(A): | |
def _open(self): | |
pass |
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 'spec_helper' | |
describe User do | |
it{ should have_field(:email).of_type(String) } | |
it{ should have_field(:username).of_type(String) } | |
it{ should have_field(:password_hash).of_type(String) } | |
it{ should have_field(:password_salt).of_type(String) } | |
it{ should have_field(:activation_token).of_type(String) } |
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 Mongoid | |
module Mutation | |
def as(klass, extra_attributes={}) | |
klass.new(attributes_for(klass, extra_attributes)).tap do |mutation| | |
mutation.new_record = new_record? | |
mutation.send(:modifications)['_type'] = [self._type, klass.name] | |
end | |
end |
OlderNewer