fantastic_currency 0.1.2 → 0.1.3
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/Rakefile +1 -1
- data/fantastic_currency.gemspec +2 -2
- data/lib/fantastic_currency.rb +3 -1
- metadata +2 -2
data/Rakefile
CHANGED
|
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
|
2
2
|
require 'rake'
|
|
3
3
|
require 'echoe'
|
|
4
4
|
|
|
5
|
-
Echoe.new('fantastic_currency', '0.1.
|
|
5
|
+
Echoe.new('fantastic_currency', '0.1.3') do |p|
|
|
6
6
|
p.description = "Manage currencies with Active Record"
|
|
7
7
|
p.url = "http://github.com/iamcalledrob/FantasticCurrency"
|
|
8
8
|
p.author = "Rob Mason"
|
data/fantastic_currency.gemspec
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Gem::Specification.new do |s|
|
|
4
4
|
s.name = %q{fantastic_currency}
|
|
5
|
-
s.version = "0.1.
|
|
5
|
+
s.version = "0.1.3"
|
|
6
6
|
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
|
8
8
|
s.authors = ["Rob Mason"]
|
|
9
|
-
s.date = %q{2010-02-
|
|
9
|
+
s.date = %q{2010-02-23}
|
|
10
10
|
s.description = %q{Manage currencies with Active Record}
|
|
11
11
|
s.email = %q{info+gems@slightlyfantastic.com}
|
|
12
12
|
s.extra_rdoc_files = ["README.textile", "lib/fantastic_currency.rb"]
|
data/lib/fantastic_currency.rb
CHANGED
|
@@ -26,7 +26,7 @@ module FantasticCurrency
|
|
|
26
26
|
value = BigDecimal.new(value.to_s) * 10**FantasticCurrency::Config.get_currency(options[:currency])[:precision]
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
-
if options[:convert_to]
|
|
29
|
+
if options[:convert_to] and options[:convert_to] != options[:currency]
|
|
30
30
|
source_currency = FantasticCurrency::Config.get_currency(options[:currency])
|
|
31
31
|
dest_currency = FantasticCurrency::Config.get_currency(options[:convert_to])
|
|
32
32
|
value = value * BigDecimal.new(source_currency[:nominal_value].to_s) / BigDecimal.new(dest_currency[:nominal_value].to_s)
|
|
@@ -114,6 +114,8 @@ module FantasticCurrency
|
|
|
114
114
|
format_currency(self[field_name], { :currency => self[:currency] }.merge(args.first || {}))
|
|
115
115
|
end
|
|
116
116
|
end
|
|
117
|
+
|
|
118
|
+
alias_method "#{field_name.to_s}_before_type_cast", "#{field_name}"
|
|
117
119
|
|
|
118
120
|
define_method "#{field_name.to_s}=" do |value|
|
|
119
121
|
raise "Money doesn't float!" if value.class.name == "Float"
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fantastic_currency
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Rob Mason
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
|
|
12
|
-
date: 2010-02-
|
|
12
|
+
date: 2010-02-23 00:00:00 -05:00
|
|
13
13
|
default_executable:
|
|
14
14
|
dependencies: []
|
|
15
15
|
|