acts_as_money 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/acts_as_money.rb +14 -1
- metadata +4 -4
data/lib/acts_as_money.rb
CHANGED
@@ -23,7 +23,20 @@ module ActsAsMoney #:nodoc:
|
|
23
23
|
[(options[:cents] || :cents).to_s, 'cents'],
|
24
24
|
[(options[:currency] || :currency).to_s, 'currency_as_string']
|
25
25
|
],
|
26
|
-
:constructor => lambda {|cents, currency| options[:allow_nil] && !cents ? nil : Money.new(cents || 0, currency || Money.default_currency)}
|
26
|
+
:constructor => lambda {|cents, currency| options[:allow_nil] && !cents ? nil : Money.new(cents || 0, currency || Money.default_currency)},
|
27
|
+
:converter => lambda { |value|
|
28
|
+
case value
|
29
|
+
when Fixnum
|
30
|
+
Money.new(value, Money.default_currency)
|
31
|
+
when Float
|
32
|
+
Money.new((value * 100).to_i, Money.default_currency)
|
33
|
+
when String
|
34
|
+
Money.new((value.to_f * 100).to_i, Money.default_currency)
|
35
|
+
else
|
36
|
+
value
|
37
|
+
end
|
38
|
+
|
39
|
+
}
|
27
40
|
}
|
28
41
|
end
|
29
42
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_money
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 3
|
10
|
+
version: 0.2.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Tim Cowlishaw
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-12-
|
18
|
+
date: 2010-12-22 00:00:00 +00:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|