laundry 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -94,15 +94,12 @@ module Laundry
94
94
  def client(&block)
95
95
  self.class.client(&block)
96
96
  end
97
-
98
- def default_body(hash)
99
- @default_body = hash
100
- end
101
-
97
+
102
98
  private
103
99
 
104
100
  def merged_default_body(body = {})
105
- (@default_body || {}).merge (body || {})
101
+ default = self.respond_to?(:default_body) ? self.default_body : nil
102
+ (default || {}).merge (body || {})
106
103
  end
107
104
 
108
105
  end.tap { |mod| include(mod) }
@@ -22,6 +22,7 @@ module Laundry
22
22
 
23
23
  # Returns the payment method id
24
24
  def create!(options = {})
25
+ raise ArgumentError, "Tried to create an account on an invalid client." if self.client.nil? || self.client.blank?
25
26
  options = {merchant_id: self.merchant.id, client_id: self.client.id, payment_method_id: 0}.merge(options)
26
27
  options = AccountDriver.uglify_hash(options)
27
28
  r = client_driver.create_payment_method({'payment' => options}) do
@@ -9,9 +9,11 @@ module Laundry
9
9
  def initialize(merchant)
10
10
  # Save the merchant.
11
11
  self.merchant = merchant
12
+ end
12
13
 
14
+ def default_body
13
15
  # Log in via the merchant's login credentials.
14
- default_body self.merchant.login_credentials.merge("MerchantID" => self.merchant.id)
16
+ self.merchant.login_credentials.merge("MerchantID" => self.merchant.id)
15
17
  end
16
18
 
17
19
  def self.prettifiable_fields
@@ -19,8 +19,12 @@ module Laundry
19
19
  record
20
20
  end
21
21
 
22
+ def blank?
23
+ record == {} || record.nil? || !record
24
+ end
25
+
22
26
  def method_missing(id, *args)
23
- return record[id.to_sym] if record.try(:has_key?, id.to_sym)
27
+ return record[id.to_sym] if record.is_a?(Hash) && record.has_key?(id.to_sym)
24
28
  super
25
29
  end
26
30
 
@@ -1,3 +1,3 @@
1
1
  module Laundry
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: laundry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-08 00:00:00.000000000 Z
12
+ date: 2012-08-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: savon
@@ -70,7 +70,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
70
70
  version: '0'
71
71
  segments:
72
72
  - 0
73
- hash: 2170319772523828423
73
+ hash: -1941831342828825987
74
74
  required_rubygems_version: !ruby/object:Gem::Requirement
75
75
  none: false
76
76
  requirements:
@@ -79,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
79
  version: '0'
80
80
  segments:
81
81
  - 0
82
- hash: 2170319772523828423
82
+ hash: -1941831342828825987
83
83
  requirements: []
84
84
  rubyforge_project:
85
85
  rubygems_version: 1.8.24