dm-money 0.1.1 → 0.1.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.
- data/Gemfile +1 -0
- data/VERSION +1 -1
- data/lib/dm-money.rb +2 -2
- data/test/test_money.rb +11 -3
- metadata +2 -2
data/Gemfile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/lib/dm-money.rb
CHANGED
@@ -53,12 +53,12 @@ module DataMapper
|
|
53
53
|
name_amount = "#{name}_amount"
|
54
54
|
name_currency = "#{name}_currency"
|
55
55
|
|
56
|
-
options_amount = options.only(:required, :
|
56
|
+
options_amount = options.only(:required, :precision, :scale).merge(:accessor => :private)
|
57
57
|
options_amount.merge!(:default => default.amount) if default
|
58
58
|
self.property name_amount.to_sym, BigDecimal, options_amount
|
59
59
|
|
60
60
|
options_currency = options.only(:required).merge(:accessor => :private, :length => 3)
|
61
|
-
options_currency.merge!(:default => default.currency) if default
|
61
|
+
options_currency.merge!(:default => default.currency.to_s) if default
|
62
62
|
self.property name_currency.to_sym, String, options_currency
|
63
63
|
|
64
64
|
# TODO: Access amount, currency via readers or properties?
|
data/test/test_money.rb
CHANGED
@@ -8,7 +8,7 @@ class TestMoney < Test::Unit::TestCase
|
|
8
8
|
include DataMapper::Resource
|
9
9
|
property :id, Serial
|
10
10
|
property :type, String
|
11
|
-
money :price, :default => BigMoney.new(
|
11
|
+
money :price, :default => BigMoney.new(1, :aud)
|
12
12
|
end # Cake
|
13
13
|
end
|
14
14
|
|
@@ -28,10 +28,18 @@ class TestMoney < Test::Unit::TestCase
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
should 'have
|
32
|
-
price = BigMoney.new(
|
31
|
+
should 'have default' do
|
32
|
+
price = BigMoney.new(1, :aud)
|
33
33
|
cake = Cake.create(:type => 'banana')
|
34
34
|
assert_equal price, cake.price
|
35
35
|
end
|
36
|
+
|
37
|
+
should 'have default currency' do
|
38
|
+
assert_equal BigMoney.currency(:aud).to_s, Cake.properties[:price_currency].default
|
39
|
+
end
|
40
|
+
|
41
|
+
should 'have default amount' do
|
42
|
+
assert_equal BigDecimal.new('1'), Cake.properties[:price_amount].default
|
43
|
+
end
|
36
44
|
end
|
37
45
|
end # TestMoney
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dm-money
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shane Hanna
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-02-
|
12
|
+
date: 2010-02-24 00:00:00 +11:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|