money 1.5 → 1.5.6

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.
Files changed (3) hide show
  1. data/README +1 -1
  2. data/lib/money/money.rb +7 -1
  3. metadata +3 -3
data/README CHANGED
@@ -22,7 +22,7 @@ Alternatively you can get the library packed
22
22
 
23
23
  http://dist.leetsoft.com/pkg/
24
24
 
25
- == Useage
25
+ == Usage
26
26
 
27
27
  Use the compose_of helper to let active record deal with embedding the money
28
28
  object in your models. The following example requires a cents and a currency field.
data/lib/money/money.rb CHANGED
@@ -66,7 +66,10 @@ class Money
66
66
  end
67
67
 
68
68
  def +(other_money)
69
- if self.cents == 0 or currency == other_money.currency
69
+ return other_money.dup if cents.zero?
70
+ return dup if other_money.cents.zero?
71
+
72
+ if currency == other_money.currency
70
73
  Money.new(cents + other_money.cents, other_money.currency)
71
74
  else
72
75
  Money.new(cents + other_money.exchange_to(currency).cents,currency)
@@ -74,6 +77,9 @@ class Money
74
77
  end
75
78
 
76
79
  def -(other_money)
80
+ return other_money.dup if cents.zero?
81
+ return dup if other_money.cents.zero?
82
+
77
83
  if self.cents == 0 or currency == other_money.currency
78
84
  Money.new(cents - other_money.cents, other_money.currency)
79
85
  else
metadata CHANGED
@@ -3,15 +3,15 @@ rubygems_version: 0.8.10
3
3
  specification_version: 1
4
4
  name: money
5
5
  version: !ruby/object:Gem::Version
6
- version: "1.5"
7
- date: 2005-07-20
6
+ version: 1.5.6
7
+ date: 2005-07-22
8
8
  summary: Class aiding in the handling of Money.
9
9
  require_paths:
10
10
  - lib
11
11
  email: tobi@leetsoft.com
12
12
  homepage: http://leetsoft.com/rails/money
13
13
  rubyforge_project:
14
- description: Can be used as composite in ActiveRecord tables.
14
+ description: Class aiding in the handling of Money and Currencies.\nIt supports easy pluggable bank objects for customized exchange strategies.\nCan be used as composite in ActiveRecord tables.
15
15
  autorequire: money
16
16
  default_executable:
17
17
  bindir: bin