scrooge 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/scrooge.rb +5 -3
- data/lib/scrooge/active_record.rb +1 -1
- data/scrooge.gemspec +2 -2
- metadata +2 -2
data/lib/scrooge.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
+
require "bigdecimal"
|
2
|
+
|
1
3
|
module Scrooge
|
2
|
-
VERSION = "0.1.
|
4
|
+
VERSION = "0.1.2"
|
3
5
|
|
4
6
|
class Money
|
5
7
|
include Comparable
|
@@ -22,7 +24,7 @@ module Scrooge
|
|
22
24
|
end
|
23
25
|
|
24
26
|
def to_f
|
25
|
-
to_cents / 100
|
27
|
+
BigDecimal(to_cents.to_s) / BigDecimal("100")
|
26
28
|
end
|
27
29
|
|
28
30
|
def to_money
|
@@ -91,7 +93,7 @@ end
|
|
91
93
|
|
92
94
|
class String
|
93
95
|
def to_money
|
94
|
-
|
96
|
+
BigDecimal(self).to_money
|
95
97
|
end
|
96
98
|
|
97
99
|
def as_cents
|
@@ -7,7 +7,7 @@ module Scrooge
|
|
7
7
|
composed_of name, :class_name => "Scrooge::Money",
|
8
8
|
:mapping => ["#{name}_in_cents", "to_cents"],
|
9
9
|
:converter => lambda {|value| Money.parse(value || 0) },
|
10
|
-
:constructor => lambda {|value| value.
|
10
|
+
:constructor => lambda {|value| BigDecimal(value.to_s).as_cents }
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
data/scrooge.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "scrooge"
|
3
|
-
s.version = "0.1.
|
4
|
-
s.date = "2010-01-
|
3
|
+
s.version = "0.1.2"
|
4
|
+
s.date = "2010-01-28"
|
5
5
|
|
6
6
|
s.description = "Class to serialize money into the database, works out of the box with ActiveRecord"
|
7
7
|
s.summary = "Scrooge will keep all your money safe. Or at least in the database."
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scrooge
|
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
|
- "Nicol\xC3\xA1s Sanguinetti"
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-01-
|
12
|
+
date: 2010-01-28 00:00:00 -02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|