currency_conversion 0.0.3.1 → 0.0.3.2

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.
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'currency_conversion'
3
- s.version = '0.0.3.1'
3
+ s.version = '0.0.3.2'
4
4
  s.summary = "Currency Conversion"
5
5
  s.description = "Currency conversion gem"
6
6
  s.add_runtime_dependency 'rest-client', ['~> 1.6.7']
@@ -1,5 +1,5 @@
1
- require "currency_conversion/model"
2
1
 
2
+ require "currency_conversion/model"
3
3
  module CurrencyConversion
4
4
 
5
5
  end
@@ -1,14 +1,25 @@
1
1
  require "currency_conversion/gateway.rb"
2
2
  module CurrencyConversion
3
3
  module Model
4
- def conversion_fields(*fields)
5
- fields.each do |field|
6
- define_method "#{field.to_s}_to" do |args, from="usd"|
7
- return self.send(field) if args.nil? || ( args == "usd" && from == "usd" )
8
- @gateway = CurrencyConversion::Gateway.new value: self.send(field), from: from , to: args
9
- @gateway.convert_payment
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.1
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-03 00:00:00.000000000 Z
13
+ date: 2013-05-27 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rest-client