currency_conversion 0.0.3.1 → 0.0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/currency_conversion.gemspec +1 -1
- data/lib/currency_conversion.rb +1 -1
- data/lib/currency_conversion/model.rb +17 -6
- metadata +2 -2
data/currency_conversion.gemspec
CHANGED
data/lib/currency_conversion.rb
CHANGED
@@ -1,14 +1,25 @@
|
|
1
1
|
require "currency_conversion/gateway.rb"
|
2
2
|
module CurrencyConversion
|
3
3
|
module Model
|
4
|
-
def
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
def self.included base
|
5
|
+
base.send :include, InstanceMethods
|
6
|
+
base.extend ClassMethods
|
7
|
+
end
|
8
|
+
module ClassMethods
|
9
|
+
def conversion_fields(*fields)
|
10
|
+
fields.each do |field|
|
11
|
+
define_method "#{field.to_s}_to" do |args, from="usd"|
|
12
|
+
return self.send(field) if args.nil? || ( args == "usd" && from == "usd" )
|
13
|
+
make_transaction self.send(field), from, args
|
14
|
+
end
|
10
15
|
end
|
11
16
|
end
|
12
17
|
end
|
18
|
+
module InstanceMethods
|
19
|
+
def make_transaction(ammount, from, to)
|
20
|
+
@gateway = CurrencyConversion::Gateway.new value: ammount, from: from , to: to
|
21
|
+
@gateway.convert_payment
|
22
|
+
end
|
23
|
+
end
|
13
24
|
end
|
14
25
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: currency_conversion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.3.
|
4
|
+
version: 0.0.3.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-05-
|
13
|
+
date: 2013-05-27 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rest-client
|