-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from rehevkor5/feature/obey_inverse_of
Obey inverse_of
- Loading branch information
Showing
9 changed files
with
244 additions
and
67 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
source "http://rubygems.org" | ||
gemspec | ||
|
||
gem "rake" | ||
gem "bson_ext" | ||
|
||
group :development do | ||
gem "jeweler" | ||
gem "guard-rspec" | ||
end | ||
|
||
group :test do | ||
gem "pry" | ||
gem "rspec" | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
PATH | ||
remote: . | ||
specs: | ||
mongoid_denormalize (0.3.0) | ||
mongoid (>= 2.1.9) | ||
|
||
GEM | ||
remote: http://rubygems.org/ | ||
specs: | ||
activemodel (3.2.3) | ||
activesupport (= 3.2.3) | ||
builder (~> 3.0.0) | ||
activesupport (3.2.3) | ||
i18n (~> 0.6) | ||
multi_json (~> 1.0) | ||
bson (1.6.2) | ||
bson_ext (1.6.2) | ||
bson (~> 1.6.2) | ||
builder (3.0.0) | ||
coderay (1.0.6) | ||
diff-lcs (1.1.3) | ||
ffi (1.0.11) | ||
git (1.2.5) | ||
guard (1.0.1) | ||
ffi (>= 0.5.0) | ||
thor (~> 0.14.6) | ||
guard-rspec (0.7.0) | ||
guard (>= 0.10.0) | ||
i18n (0.6.0) | ||
jeweler (1.8.3) | ||
bundler (~> 1.0) | ||
git (>= 1.2.5) | ||
rake | ||
rdoc | ||
json (1.6.6) | ||
method_source (0.7.1) | ||
mongo (1.6.2) | ||
bson (~> 1.6.2) | ||
mongoid (2.4.8) | ||
activemodel (~> 3.1) | ||
mongo (~> 1.3) | ||
tzinfo (~> 0.3.22) | ||
multi_json (1.3.2) | ||
pry (0.9.9.3) | ||
coderay (~> 1.0.5) | ||
method_source (~> 0.7.1) | ||
slop (>= 2.4.4, < 3) | ||
rake (0.9.2.2) | ||
rdoc (3.12) | ||
json (~> 1.4) | ||
rspec (2.9.0) | ||
rspec-core (~> 2.9.0) | ||
rspec-expectations (~> 2.9.0) | ||
rspec-mocks (~> 2.9.0) | ||
rspec-core (2.9.0) | ||
rspec-expectations (2.9.1) | ||
diff-lcs (~> 1.1.3) | ||
rspec-mocks (2.9.0) | ||
slop (2.4.4) | ||
thor (0.14.6) | ||
tzinfo (0.3.33) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
bson_ext | ||
guard-rspec | ||
jeweler | ||
mongoid_denormalize! | ||
pry | ||
rake | ||
rspec |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# vim:set filetype=ruby: | ||
# A sample Guardfile | ||
# More info at https://github.com/guard/guard#readme | ||
|
||
guard :rspec, all_after_pass: false, cli: "--fail-fast --tty --format documentation --colour" do | ||
watch(%r{^spec/.+_spec\.rb$}) | ||
watch(%r{^lib/(.+)\.rb$}) { |match| "spec/#{match[1]}_spec.rb" } | ||
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
require "benchmark" | ||
require 'rubygems' | ||
require 'mongoid' | ||
|
||
Mongoid.configure do |config| | ||
config.master = Mongo::Connection.new.db("mongoid_denormalize_development") | ||
end | ||
|
||
def bm(context = "") | ||
print("#{context}\t") | ||
Benchmark.bm do |bm| | ||
[10, 100, 1000, 10000].each do |i| | ||
@user = User.create | ||
i.times do | ||
@user.articles.create | ||
end | ||
|
||
bm.report("#{i}\t") do | ||
@user.update_attributes :name => 'John Doe', :email => 'john@doe.com' | ||
end | ||
|
||
@user.articles.destroy_all | ||
@user.delete | ||
end | ||
end | ||
end | ||
|
||
lib_path = 'lib/mongoid_denormalize.rb' | ||
lib_full_path = File.expand_path("../#{lib_path}", __FILE__) | ||
|
||
eval `git show a83c4fc3e86f19f9c494b9f068f3bd44d876db1a:#{lib_path}` | ||
Dir["#{File.dirname(__FILE__)}/spec/app/models/*.rb"].each { |f| require f } | ||
bm "Before" | ||
|
||
load lib_full_path | ||
bm "After" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
class Article | ||
include Mongoid::Document | ||
include Mongoid::Denormalize | ||
|
||
field :title | ||
field :body | ||
field :created_at, :type => Time | ||
|
||
belongs_to :author, :class_name => 'User' | ||
|
||
denormalize :name, :email, :from => :author | ||
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
Oops, something went wrong.