calculable_attrs 0.0.7 → 0.0.8
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2cb90fc5396803596c76b7179e003580f5325a57
|
4
|
+
data.tar.gz: a6d5fa763da75d215749063635f0aec3a787c5ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8cd92421d55e7e32b2f742721851f7d2285165a5be5db5066195669e7d03bfa31e78aa767a4b224ade25939ed3b0b48491d7ddad984a35d1bfe45a280206eeed
|
7
|
+
data.tar.gz: 07fc087b96843bc8be86ff3053a1f06226c2806a86b721a1722e1fb790ecdeba34917b236ac2a0ca998ff298f0527f0a3217e643542ded97a78870ce4e9aca7b
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class CalculableAttrs::Calculator
|
2
2
|
CALCULABLE_FOREIGN_KEY = '__calculable_id__'
|
3
|
-
attr_reader :attrs
|
3
|
+
attr_reader :attrs, :relation, :foreign_key
|
4
4
|
|
5
5
|
def initialize(relation: nil, foreign_key: nil, attributes: nil)
|
6
6
|
@relation = relation
|
@@ -40,6 +40,14 @@ class CalculableAttrs::Calculator
|
|
40
40
|
calculate(attrs, id)
|
41
41
|
end
|
42
42
|
|
43
|
+
def base_query(attrs, id)
|
44
|
+
scoped_relation(id).select(build_select(attrs))
|
45
|
+
end
|
46
|
+
|
47
|
+
def scoped_relation(id)
|
48
|
+
@relation.call.where( @foreign_key => id)
|
49
|
+
end
|
50
|
+
|
43
51
|
private
|
44
52
|
|
45
53
|
def save_attribute_value(name, value)
|
@@ -58,9 +66,6 @@ class CalculableAttrs::Calculator
|
|
58
66
|
end
|
59
67
|
end
|
60
68
|
|
61
|
-
def base_query(attrs, id)
|
62
|
-
@relation.call.select(build_select(attrs)).where( @foreign_key => id)
|
63
|
-
end
|
64
69
|
|
65
70
|
def normalize_many_records_result(ids, attrs, records)
|
66
71
|
normalized = {}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: calculable_attrs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitry Sharkov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|