occams-record 0.3.0 → 0.4.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
  SHA1:
3
- metadata.gz: 93cf9f49f91eee71e3ad4f920ab2a6be8f212363
4
- data.tar.gz: 0b213d2fc9d5882a4c387e94989af64d96c0b037
3
+ metadata.gz: 626b915405cadac96171e3283e1f05172ff5a272
4
+ data.tar.gz: bb347409b11e0c9602520a2444b56bb751c1f0e8
5
5
  SHA512:
6
- metadata.gz: 34f6973012cdae863862cf6a8850442d18333f320bd5920866d1f7bd402dc6530bcadb76bece429512b6ec6c5a527afbdf8d1d8041145ff5691071c95ee9dba0
7
- data.tar.gz: 2068ccf8a5c863ac5c9a63f5df408b6d3fafda5cca6b0bb292873397480048f985e89c8d27e9ce08dcc80890c72f2720172c477baa527e00c51e526b04f7a5d9
6
+ metadata.gz: 480de46340d39119a7e2b9b2734db2ac204d938e4313eef0b50d3ea39fb575683c84c78455a4f9492891f36074acdf611d634702f3d1d353df1722e60f75ed11
7
+ data.tar.gz: 5ddc0ad13f4d214e921341e88428e2e40bfac204f6e377343110ac7ca875ac668722361261f7d35cc9cfa2f3fb70465082725db118c02467086d339727210b08
data/README.md CHANGED
@@ -82,7 +82,7 @@ widgets = OccamsRecord.
82
82
  eager_load(:order_items, select: "widget_id, order_id") {
83
83
 
84
84
  # load the orders
85
- eager_load(:orders, -> { order "order_date DESC" }) {
85
+ eager_load(:orders, -> { select("id, customer_id").order("order_date DESC") }) {
86
86
 
87
87
  # load the customers who made the orders, but only their names
88
88
  eager_load(:customer, select: "id, name")
@@ -130,6 +130,13 @@ widgets[0].orders[0].description
130
130
  => "O839SJZ98B 1/8/2017"
131
131
  ```
132
132
 
133
+ ## Unsupported features
134
+
135
+ The following `ActiveRecord` are not supported, and I have no plans to do so. However, I'd be glad to accept pull requests.
136
+
137
+ * ActiveRecord enum types
138
+ * ActiveRecord serialized types
139
+
133
140
  ## Testing
134
141
 
135
142
  To run the tests, simply run:
@@ -20,20 +20,20 @@ module OccamsRecord
20
20
  #
21
21
  def merge!(assoc_rows, rows)
22
22
  joins_by_id = join_rows(rows).reduce({}) { |a, join|
23
- id = join[0]
23
+ id = join[0].to_s
24
24
  a[id] ||= []
25
- a[id] << join[1]
25
+ a[id] << join[1].to_s
26
26
  a
27
27
  }
28
28
 
29
29
  assoc_rows_by_id = assoc_rows.reduce({}) { |a, row|
30
- id = row.send @ref.association_primary_key
30
+ id = row.send(@ref.association_primary_key).to_s
31
31
  a[id] = row
32
32
  a
33
33
  }
34
34
 
35
35
  rows.each do |row|
36
- id = row.send @ref.active_record_primary_key
36
+ id = row.send(@ref.active_record_primary_key).to_s
37
37
  assoc_fkeys = (joins_by_id[id] || []).uniq
38
38
  associations = assoc_rows_by_id.values_at(*assoc_fkeys).compact.uniq
39
39
  row.send @assign, associations
@@ -3,5 +3,5 @@
3
3
  #
4
4
  module OccamsRecord
5
5
  # Library version
6
- VERSION = '0.3.0'.freeze
6
+ VERSION = '0.4.0'.freeze
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: occams-record
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jordan Hollinger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-23 00:00:00.000000000 Z
11
+ date: 2017-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord