amountable 0.2.1 → 0.2.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 +4 -4
- data/lib/amountable.rb +7 -3
- data/lib/amountable/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0856ee3834afef77888546b862d8cb200ccf6d38
|
|
4
|
+
data.tar.gz: 35153d7985332e50a55f1183cd7afbf578e182ff
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2e7c8be8ae3df1bbbefe8b1805ed0c78ae1e90eb26c1af053c29411e05774f1f3fc538ee29d1d8a25c608b658e35699551bb21b79aef37a47c9d55355b68d50a
|
|
7
|
+
data.tar.gz: b36bc482f7df0a01767174f08ba3ec0eaf68bf7e3889ff50dcb61f944c37dc1e27a7c8ccb3b6b8c944270badd9c5704400baef728d6d20551651bf9d4e5a0e17
|
data/lib/amountable.rb
CHANGED
|
@@ -15,7 +15,7 @@ module Amountable
|
|
|
15
15
|
ALLOWED_STORAGE = %i(table json).freeze
|
|
16
16
|
|
|
17
17
|
def self.included(base)
|
|
18
|
-
base.extend Amountable::
|
|
18
|
+
base.extend Amountable::ActAsMethod
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
module InstanceMethods
|
|
@@ -52,10 +52,11 @@ module Amountable
|
|
|
52
52
|
end
|
|
53
53
|
end
|
|
54
54
|
|
|
55
|
-
module
|
|
55
|
+
module ActAsMethod
|
|
56
56
|
|
|
57
57
|
# Possible storage values: [:table, :jsonb]
|
|
58
58
|
def act_as_amountable(options = {})
|
|
59
|
+
self.extend Amountable::ClassMethod
|
|
59
60
|
class_attribute :amount_names
|
|
60
61
|
class_attribute :amount_sets
|
|
61
62
|
class_attribute :amounts_column_name
|
|
@@ -79,6 +80,9 @@ module Amountable
|
|
|
79
80
|
include Amountable::InstanceMethods
|
|
80
81
|
end
|
|
81
82
|
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
module ClassMethod
|
|
82
86
|
def amount_set(set_name, component)
|
|
83
87
|
self.amount_sets[set_name.to_sym] << component.to_sym
|
|
84
88
|
|
|
@@ -140,7 +144,7 @@ module Amountable
|
|
|
140
144
|
elsif name.in?(self.amount_sets.keys)
|
|
141
145
|
'sets'
|
|
142
146
|
end
|
|
143
|
-
"#{self.amounts_column_name}::json
|
|
147
|
+
"#{self.amounts_column_name}::json#>'{#{group},#{name},#{field}}'"
|
|
144
148
|
end
|
|
145
149
|
|
|
146
150
|
end
|
data/lib/amountable/version.rb
CHANGED