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 +4 -4
- data/lib/amountable/amount.rb +14 -1
- data/lib/amountable/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c37c1a1882d94206f8154a689c1055bc026e854
|
4
|
+
data.tar.gz: 15766a308868b41811f11b4d5d6912b10ab1319b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e60727be4b0b233bec117154cbb8b1cd52d5851a6afd55b27a55ba5c8a6547dee5b16f2e77ef301db6407749e2fd53911786072e00bd5bdd545933d33a08a667
|
7
|
+
data.tar.gz: 0a7dc794e917cca74ec4d1087071a482dd6013f5d8c6c401e8662c607b8811788409e7035ec5edc6e7fbf0347c30191c6c4117a7dd74ac7eda8d526502001d4c
|
data/lib/amountable/amount.rb
CHANGED
@@ -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]}
|
data/lib/amountable/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2016-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|