quickery 0.1.1 → 0.1.2

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: 2f70692a2f4e06fd43908254b29130a6216a7c2601fcd80f82375a31bfd03931
4
- data.tar.gz: '079641a4f8fba9b911442849a4d8cff55c39b4668904b76e7e807e6f167b73e8'
3
+ metadata.gz: f23d071c0950a5aea01e1fbaac6b70b8024afc869309116947c0b9bf093e5869
4
+ data.tar.gz: ded1a4a4900160e8e614ad09ffcf824b6f7fde68fdc9c2b4d61d1fe2bc650ec1
5
5
  SHA512:
6
- metadata.gz: f719cb216c2f99ee6268088f630180d4dd190942fa96ae85062a00ff2613342b2cd34a4ac295b8c03ce833bf245c3d76c7fa17459695bc29fb95cf54ee989555
7
- data.tar.gz: b7aff203442a9a8b6d16cbb138aaa5193bc2ab409efc769a9eeccc907bc13feee423381e3b76a7cc69d38e2e1afc7988d6dc4abb25ee112995bf8df35862982b
6
+ metadata.gz: 0fa75bd9539cfd2095beb17099685c83ef0c617723c829bdbbc6041c791292f1f5d8cd98561aca87e69655c2c1850d4f18e4c4615ef67108c662c6c047ffe0d9
7
+ data.tar.gz: 8f3be6901dd857c976b1d08e54245f7b9d249dc7738f59e4ddbf411e24bca40e36a43304ebc730af74f7f472ef307982ea165fe6f47dbc657e15a47741785a23
data/.gitignore CHANGED
File without changes
data/.rspec CHANGED
File without changes
File without changes
data/Appraisals CHANGED
File without changes
data/Gemfile CHANGED
@@ -4,6 +4,7 @@ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
4
 
5
5
  group :development, :test do
6
6
  gem 'factory_bot_rails', require: false
7
+ gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw]
7
8
  end
8
9
 
9
10
  # Specify your gem's dependencies in quickery.gemspec
data/Guardfile CHANGED
File without changes
File without changes
data/README.md CHANGED
@@ -3,8 +3,6 @@
3
3
  [![Build Status](https://travis-ci.org/jrpolidario/quickery.svg?branch=master)](https://travis-ci.org/jrpolidario/quickery)
4
4
  [![Gem Version](https://badge.fury.io/rb/quickery.svg)](https://badge.fury.io/rb/quickery)
5
5
 
6
- ## About
7
-
8
6
  * Implements Law of Demeter by mapping associated record attributes as own attributes (one-way read-only)
9
7
  * Consequently, speeds up SQL queries by removing joins queries between intermediary models, at the cost of slower writes.
10
8
  * This is an anti-normalization pattern in favour of actual data-redundancy and faster queries. Use this only as necessary.
@@ -33,8 +31,9 @@
33
31
  # app/models/employee.rb
34
32
  class Employee < ApplicationRecord
35
33
  # say we have the following attributes:
36
- # branch_id:integer
34
+ # branch_id:bigint
37
35
  # branch_company_name:string
36
+
38
37
  belongs_to :branch
39
38
 
40
39
  quickery do
@@ -58,7 +57,8 @@ end
58
57
  # app/models/branch.rb
59
58
  class Branch < ApplicationRecord
60
59
  # say we have the following attributes:
61
- # company_id:integer
60
+ # company_id:bigint
61
+
62
62
  belongs_to :company
63
63
  end
64
64
 
@@ -92,7 +92,7 @@ company.update!(name: 'Mang Inasal')
92
92
  puts employee.branch_company_name
93
93
  # => 'Jollibee'
94
94
 
95
- # You need to reload the object, if you expect that it's been changed:
95
+ # You may or may not need to reload the object, depending on if you expect that it's been changed:
96
96
  employee.reload
97
97
 
98
98
  puts employee.branch_company_name
@@ -108,6 +108,15 @@ puts employee.branch_company_name
108
108
  # => 'McDonalds'
109
109
  ```
110
110
 
111
+ If you already have "old" records before you've integrated quickery or if you have new quickery-defined attributes, you can update these stale records by using `recreate_quickery_cache!`. See example below:
112
+
113
+ ```ruby
114
+ # rails console
115
+ Employee.find_each do |employee|
116
+ employee.recreate_quickery_cache!
117
+ end
118
+ ```
119
+
111
120
  ## Usage Example 2
112
121
 
113
122
  * let `Branch` and `Company` model be the same as the Usage Example 1 above
@@ -116,7 +125,7 @@ puts employee.branch_company_name
116
125
  # app/models/employee.rb
117
126
  class Employee < ApplicationRecord
118
127
  belongs_to :branch
119
- belongs_to :country, foreign_key: :branch_company_id
128
+ belongs_to :company, foreign_key: :branch_company_id
120
129
 
121
130
  quickery do
122
131
  branch.company.id == :branch_company_id
@@ -143,7 +152,7 @@ puts Employee.where(company: company)
143
152
  # => [#<Employee id: 1>]
144
153
 
145
154
  # as you may notice, the query above is a lot simpler and faster instead of doing it normally like below (if not using Quickery)
146
- # you may however still using belongs_to `:through` to achieve the simplified query like above, but it's still a lot slower because of JOINS
155
+ # you may however still use belongs_to `:through` to achieve the simplified query like above, but it's still a lot slower because of JOINS
147
156
  puts Employee.joins(branch: :company).where(companies: { id: company.id })
148
157
  # => [#<Employee id: 1>]
149
158
  ```
@@ -179,7 +188,7 @@ puts Employee.joins(branch: :company).where(companies: { id: company.id })
179
188
  * useful if you already have records, and you want these old records to be updated immediately
180
189
  * i.e. you can do so something like the following:
181
190
  ```ruby
182
- Employee.each do |employee|
191
+ Employee.find_each do |employee|
183
192
  employee.recreate_quickery_cache!
184
193
  end
185
194
  ```
@@ -209,6 +218,8 @@ puts Employee.joins(branch: :company).where(companies: { id: company.id })
209
218
  * see [developer_guide.md](developer_guide.md)
210
219
 
211
220
  ## Changelog
221
+ * 0.1.2
222
+ * fixed require error for remnant debugging code: 'byebug'
212
223
  * 0.1.1
213
224
  * Gemspec fixes and travis build fixes.
214
225
  * 0.1.0
data/Rakefile CHANGED
File without changes
data/config.ru CHANGED
File without changes
@@ -15,6 +15,15 @@ gem push quickery-X.X.X.gem
15
15
  * [combustion](https://github.com/pat/combustion)
16
16
  * [appraisal](https://github.com/thoughtbot/appraisal)
17
17
 
18
+ ### Setup
19
+
20
+ ```bash
21
+ # setup development gems
22
+ bundle install
23
+ # setup Apprisal for testing different Rails versions below
24
+ bundle exec appraisal install
25
+ ```
26
+
18
27
  ```bash
19
28
  # to auto-test specs whenever a spec file has been modified:
20
29
  bundle exec guard
File without changes
@@ -6,6 +6,7 @@ gem "rails", "4.2.10"
6
6
 
7
7
  group :development, :test do
8
8
  gem "factory_bot_rails", require: false
9
+ gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw]
9
10
  end
10
11
 
11
12
  gemspec path: "../"
@@ -6,6 +6,7 @@ gem "rails", "5.2.1"
6
6
 
7
7
  group :development, :test do
8
8
  gem "factory_bot_rails", require: false
9
+ gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw]
9
10
  end
10
11
 
11
12
  gemspec path: "../"
File without changes
@@ -1,4 +1,3 @@
1
- require 'byebug'
2
1
  require 'active_support'
3
2
 
4
3
  module Quickery
File without changes
File without changes
File without changes
@@ -1,3 +1,3 @@
1
1
  module Quickery
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
File without changes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quickery
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jules Roman Polidario
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-09-05 00:00:00.000000000 Z
11
+ date: 2018-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -231,7 +231,6 @@ files:
231
231
  - config.ru
232
232
  - developer_guide.md
233
233
  - gemfiles/.bundle/config
234
- - gemfiles/rails_3.gemfile
235
234
  - gemfiles/rails_4.gemfile
236
235
  - gemfiles/rails_5.gemfile
237
236
  - lib/quickery.rb
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "3.2.22.5"
6
-
7
- gemspec path: "../"