mongoid_includes 3.0.3 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 48e36bb9b9e6b5ad9bef681c5ea1b2fbc041d87cc24beacb65a6fafc3454d435
4
- data.tar.gz: 361559262111d541da7f085b20ad2bf4d305e7f5d65cd5d6a511c9501c467883
3
+ metadata.gz: 83db65c1adea9fd5ce752f9867989788d8859ffd1e1b1a9fe859ebe83fcd4846
4
+ data.tar.gz: 4d8cc4f621f9f8f44bf76f33fcdb8d69be082e971d1cc961a8e430af526d4359
5
5
  SHA512:
6
- metadata.gz: bd46468001e42037d5364e5e4e08aad6f8758381d57f128244e61b92ff9b562b98414d17c4a95fad8cc1a51bcfac6623c064596a7bfdd9d405bd63b1ec721616
7
- data.tar.gz: 3ba71596e0ae09549469a0bbae88b5a3b4d8824fe64f7ce0e5d89946e917ff5631c0c7fd1d163ac7d5aaaadef5e456d8c9125f6cd8d72d8b354a42d9230261ce
6
+ metadata.gz: dbb0d5ffb72235011a22273a55acf1bbd127ac94fedb985336eecad14caf9e0b75d850e9f1e086160bac8270b1a6332cb3c4e10afa8d521766213d3171c42d83
7
+ data.tar.gz: cbd607eb7b26276e115880af07fc1b179401ed1d334a4ccb76322ebc28452ab1b2e5c983392c90eb4d2e501ac342dfc7617dd63ec709393aa62cbdf93405d481
data/README.md CHANGED
@@ -1,12 +1,11 @@
1
- Mongoid::Includes
2
- =====================
1
+ # Mongoid::Includes
3
2
 
4
3
  [![Gem Version](https://badge.fury.io/rb/mongoid_includes.svg)](https://rubygems.org/gems/mongoid_includes)
5
- [![Build Status](https://github.com/cacheventures/mongoid_includes/workflows/ci/badge.svg)](https://github.com/cacheventures/mongoid_includes/actions)
4
+ [![Build Status](https://github.com/cacheventures/mongoid_includes/workflows/CI/badge.svg)](https://github.com/cacheventures/mongoid_includes/actions)
6
5
 
7
6
  `Mongoid::Includes` improves eager loading in Mongoid, supporting polymorphic associations, and nested eager loading.
8
7
 
9
- ### Usage
8
+ ## Usage
10
9
 
11
10
  ```ruby
12
11
  Album.includes(:songs).includes(:musicians, from: :band)
@@ -19,8 +18,10 @@ released_only = ->(albums) { albums.where(released: true) }
19
18
  Musician.includes(:band, with: ->(bands) { bands.limit(2).includes(:albums, with: released_only) })
20
19
  ```
21
20
 
22
- ### Pro Tip
21
+ ## Pro Tip
22
+
23
23
  Since you can modify the queries for the associations, you can use `only` and make your queries even faster:
24
+
24
25
  ```ruby
25
26
  Band.includes :musicians, with: ->(musicians) { musicians.only(:id, :name) }
26
27
  ```
@@ -36,10 +37,10 @@ Band.includes :musicians, with: ->(musicians) { musicians.only(:id, :name) }
36
37
  Add this line to your application's Gemfile and run `bundle install`:
37
38
 
38
39
  ```ruby
39
- gem 'mongoid_includes'
40
+ gem 'mongoid_includes'
40
41
  ```
41
42
 
42
- Or install it yourself running:
43
+ Or install it yourself by running:
43
44
 
44
45
  ```sh
45
46
  gem install mongoid_includes
@@ -48,3 +49,61 @@ gem install mongoid_includes
48
49
  ## License
49
50
 
50
51
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
52
+
53
+ ## Running tests
54
+
55
+ To run the full test suite locally:
56
+
57
+ ```sh
58
+ bundle install
59
+ bundle exec rspec
60
+ # or use the bundled binary
61
+ bin/rspec
62
+ ```
63
+
64
+ To run the tests against the Mongoid 8 matrix (this project provides a separate Gemfile at `gemfiles/mongoid8.gemfile`), set `BUNDLE_GEMFILE` to that file before installing or running the suite:
65
+
66
+ ```sh
67
+ # install gems for the mongoid8 Gemfile
68
+ BUNDLE_GEMFILE=gemfiles/mongoid8.gemfile bundle install
69
+
70
+ # run the specs using that Gemfile
71
+ BUNDLE_GEMFILE=gemfiles/mongoid8.gemfile bundle exec rspec
72
+ # or
73
+ BUNDLE_GEMFILE=gemfiles/mongoid8.gemfile bin/rspec
74
+ ```
75
+
76
+ If you only need to run a single spec file while using the alternate Gemfile, pass the path to `rspec` as usual, for example:
77
+
78
+ ```sh
79
+ BUNDLE_GEMFILE=gemfiles/mongoid8.gemfile bundle exec rspec spec/mongoid/includes/criteria_spec.rb
80
+ ```
81
+
82
+ ## Contributing
83
+
84
+ Contributions are welcome. If you'd like to report a bug, suggest an improvement, or submit a patch, please follow these steps:
85
+
86
+ 1. Fork the repository on GitHub.
87
+ 2. Create a feature branch from `master` (or from the branch you're targeting):
88
+
89
+ ```sh
90
+ git switch -c my-feature-branch
91
+ ```
92
+
93
+ 3. Make your changes. Add or update tests when appropriate.
94
+ 4. Run the test suite locally to ensure everything passes:
95
+
96
+ ```sh
97
+ bundle install
98
+ bundle exec rspec
99
+ ```
100
+
101
+ 5. Commit your changes with a clear message and push your branch to your fork:
102
+
103
+ ```sh
104
+ git add -A
105
+ git commit -m "Short, descriptive message"
106
+ git push origin my-feature-branch
107
+ ```
108
+
109
+ 6. Open a Pull Request against the `master` branch of this repository. In your PR description, explain the problem, what you changed, and any notes about compatibility or required steps.
@@ -54,6 +54,7 @@ module Mongoid
54
54
  # Returns an Inclusion that can be eager loaded as usual.
55
55
  def for_class_name(class_name)
56
56
  Inclusion.new metadata.clone.instance_eval { |relation_metadata|
57
+ @options = @options.dup
57
58
  @options[:class_name] = @class_name = class_name
58
59
  @options[:polymorphic], @options[:as], @polymorphic, @klass = nil
59
60
  self
@@ -1,10 +1,5 @@
1
- # Mongoid is an ODM (Object Document Mapper) Framework for MongoDB, written in Ruby.
2
1
  module Mongoid
3
- # Improves eager loading in Mongoid, supporting polymorphic associations,
4
- # and up to two-levels of eager loading.
5
2
  module Includes
6
-
7
- # Public: This library will attempt to follow semantic versioning (whatever that's supposed to be).
8
- VERSION = '3.0.3'
3
+ VERSION = '4.0.0'.freeze
9
4
  end
10
5
  end