occams-record 0.32.0 → 0.33.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 +4 -4
- data/lib/occams-record/results.rb +14 -0
- data/lib/occams-record/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79f596ff4340bb78be9568862a4e2ed4b170cc5e5433ea5e89d039e05d12b608
|
4
|
+
data.tar.gz: 461865caca31938b4edcef8ad8301654a78d0d7f335cef094b8e939c6a02bb5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e2a1ed22da61aecccf805fbe5cfbae7abe4b9b49ffb55fc270f9166744d5e36eac8acbb4d0e6a4cb76da537a1f18daca40d28c574425d5cb12c658126f0a62c
|
7
|
+
data.tar.gz: ff1d5d5e82e39e88a7316905b9342209bd91c7c76a7b26418a48ae96344849701a4abcac2729980ace7a42be09ba6419360d49efeebde942b3e3838a9ef2c1db
|
@@ -31,6 +31,20 @@ module OccamsRecord
|
|
31
31
|
# Build getters & setters for associations. (We need setters b/c they're set AFTER the row is initialized
|
32
32
|
attr_accessor(*association_names)
|
33
33
|
|
34
|
+
# Build id getters for associations, e.g. "widget_ids" for "widgets"
|
35
|
+
self.associations.each do |assoc|
|
36
|
+
if (ref = model.reflections[assoc]) and !ref.polymorphic? and (ref.macro == :has_many or ref.macro == :has_and_belongs_to_many)
|
37
|
+
pkey = ref.association_primary_key.to_sym
|
38
|
+
define_method "#{assoc.singularize}_ids" do
|
39
|
+
begin
|
40
|
+
self.send(assoc).map(&pkey).uniq
|
41
|
+
rescue NoMethodError => e
|
42
|
+
raise MissingColumnError.new(self, e.name)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end if model
|
47
|
+
|
34
48
|
# Build a getter for each attribute returned by the query. The values will be type converted on demand.
|
35
49
|
model_column_types = model ? model.attributes_builder.types : {}
|
36
50
|
self.columns.each_with_index do |col, idx|
|
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.
|
4
|
+
version: 0.33.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: 2018-
|
11
|
+
date: 2018-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|