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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d7fb532f0098d76632e7fbc2f46ad8a79570f798
4
- data.tar.gz: df59859c26e14e795e38243b4a097059fccdffff
3
+ metadata.gz: 0856ee3834afef77888546b862d8cb200ccf6d38
4
+ data.tar.gz: 35153d7985332e50a55f1183cd7afbf578e182ff
5
5
  SHA512:
6
- metadata.gz: d1b982b2a5d90e3c28ad0905ba0154c6f2c625681a989180743cc88dd0853918186330b91afe4f05fe7c13eae7a58d7241a38e6e920053b46d4fb3737ca2563b
7
- data.tar.gz: 54a8b7d3ff9df4312b1dae3a8bc71a8a1fc063aba18ac71f055255d1b834531644b9e377657dfae7274908dafc04eacbd5872146af46139a7e05fc9a5c59c8db
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::ClassMethods
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 ClassMethods
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#>>'{#{group},#{name},#{field}}'"
147
+ "#{self.amounts_column_name}::json#>'{#{group},#{name},#{field}}'"
144
148
  end
145
149
 
146
150
  end
@@ -1,5 +1,5 @@
1
1
  # Copyright 2015-2016, Instacart
2
2
 
3
3
  module Amountable
4
- VERSION = '0.2.1'
4
+ VERSION = '0.2.2'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amountable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emmanuel Turlay