amountable 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f3bf558f623bcacd7344a073a79c0c3df320e68e
4
- data.tar.gz: f8b78e8dd441a0d9535072a0d271e80251a5ac96
3
+ metadata.gz: 1c37c1a1882d94206f8154a689c1055bc026e854
4
+ data.tar.gz: 15766a308868b41811f11b4d5d6912b10ab1319b
5
5
  SHA512:
6
- metadata.gz: 95227423a46d60a54c75c4ca5c4b130295ba8f4641c548c6e1864730133c44e3f52f7a2d678e1fbe01dce4c3ec1bd5876c886ab9ce35f785169acbbb8c7f4034
7
- data.tar.gz: 0547e0fdf70ffcdd1c3751622fa77e390fa7ab70b7b9b89c749e92ad0704ebab1debe393135b1c8861f16e667b871257b35cf35f15405e83bbd08f32669ad11c
6
+ metadata.gz: e60727be4b0b233bec117154cbb8b1cd52d5851a6afd55b27a55ba5c8a6547dee5b16f2e77ef301db6407749e2fd53911786072e00bd5bdd545933d33a08a667
7
+ data.tar.gz: 0a7dc794e917cca74ec4d1087071a482dd6013f5d8c6c401e8662c607b8811788409e7035ec5edc6e7fbf0347c30191c6c4117a7dd74ac7eda8d526502001d4c
@@ -2,12 +2,25 @@
2
2
 
3
3
  module Amountable
4
4
  class Amount < ActiveRecord::Base
5
+ class_attribute :columns
6
+ self.columns = []
7
+
8
+ def self.column(name, sql_type = nil, default = nil, null = true)
9
+ type = "ActiveRecord::Type::#{sql_type.to_s.camelize}".constantize.new
10
+ columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, type, null)
11
+ end
12
+
13
+ column :amountable_type, :string, nil, false
14
+ column :amountable_id, :integer, nil, false
15
+ column :value_currency, :string, nil, true
16
+ column :value_cents, :integer, 0, false
17
+ column :name, :string, nil, false
5
18
 
6
19
  include Amountable::Operations
7
20
 
8
21
  belongs_to :amountable, polymorphic: true
9
22
 
10
- monetize :value_cents
23
+ monetize :value_cents, with_model_currency: :value_currency
11
24
 
12
25
  validates :name, presence: true
13
26
  validates :name, uniqueness: {scope: [:amountable_id, :amountable_type]}
@@ -1,5 +1,5 @@
1
1
  # Copyright 2015-2016, Instacart
2
2
 
3
3
  module Amountable
4
- VERSION = '0.2.3'
4
+ VERSION = '0.2.4'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amountable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emmanuel Turlay
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-30 00:00:00.000000000 Z
11
+ date: 2016-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord