kontoapi-rails 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.4
1
+ 0.2.5
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "kontoapi-rails"
8
- s.version = "0.2.4"
8
+ s.version = "0.2.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jan Schwenzien"]
12
- s.date = "2012-08-03"
12
+ s.date = "2012-10-23"
13
13
  s.description = "This library is a wrapper for the Konto API (https://www.kontoapi.de/). It provides a validation method for models that checks if a given account number and bank code represent a valid combination."
14
14
  s.email = "jan@schwenzien.org"
15
15
  s.extra_rdoc_files = [
@@ -27,7 +27,7 @@ module KontoAPI
27
27
  define_method :autocomplete_bank_name do
28
28
  current_value = send(:"#{options[:bank_name_field]}")
29
29
  blz = send(:"#{options[:bank_code_field]}")
30
- blz_changed = send(:"#{options[:bank_code_field]}_changed?")
30
+ blz_changed = (respond_to?(:"#{options[:bank_code_field]}_changed?") && send(:"#{options[:bank_code_field]}_changed?")) || (respond_to?(:"encrypted_#{options[:bank_code_field]}_changed?") && send(:"encrypted_#{options[:bank_code_field]}_changed?"))
31
31
  begin
32
32
  self.send(:"#{options[:bank_name_field]}=", KontoAPI::bank_name(blz)) if (options[:always_overwrite] || current_value.blank?) && blz_changed
33
33
  return true
@@ -50,7 +50,8 @@ module KontoAPI
50
50
  options.reverse_merge!( :allow_nil => true, :on_timeout => :ignore )
51
51
  define_method :iban_validation do
52
52
  value = send(field)
53
- return true unless send(:"#{field}_changed?")
53
+ return true if respond_to?(:"#{field}_changed?") && !send(:"#{field}_changed?")
54
+ return true if respond_to?(:"encrypted_#{field}_changed?") && !send(:"encrypted_#{field}_changed?")
54
55
  return true if options[:allow_nil] && value.nil?
55
56
  begin
56
57
  errors.add(field, :invalid) unless KontoAPI::valid?( :iban => value )
@@ -71,7 +72,8 @@ module KontoAPI
71
72
  options.reverse_merge!( :allow_nil => true, :on_timeout => :ignore )
72
73
  define_method :bic_validation do
73
74
  value = send(field)
74
- return true unless send(:"#{field}_changed?")
75
+ return true if respond_to?(:"#{field}_changed?") && !send(:"#{field}_changed?")
76
+ return true if respond_to?(:"encrypted_#{field}_changed?") && !send(:"encrypted_#{field}_changed?")
75
77
  return true if options[:allow_nil] && value.nil?
76
78
  begin
77
79
  errors.add(field, :invalid) unless KontoAPI::valid?( :bic => send(field) )
@@ -6,7 +6,9 @@ module KontoAPI
6
6
  def validate(record)
7
7
  account_number = record.send(:"#{options[:account_number_field]}")
8
8
  bank_code = record.send(:"#{options[:bank_code_field]}")
9
- return true unless record.send(:"#{options[:account_number_field]}_changed?") || record.send(:"#{options[:bank_code_field]}_changed?")
9
+ account_number_changed = record.send( change_method(record, options[:account_number_field]) )
10
+ bank_code_changed = record.send( change_method(record, options[:bank_code_field]) )
11
+ return true unless account_number_changed || bank_code_changed
10
12
  return true if options[:allow_nil] && (account_number.nil? || bank_code.nil?)
11
13
  record.errors.add(:"#{options[:account_number_field]}", :invalid) unless KontoAPI::valid?( :ktn => account_number, :blz => bank_code )
12
14
  rescue Timeout::Error => ex
@@ -20,5 +22,11 @@ module KontoAPI
20
22
  end
21
23
  end
22
24
 
25
+ def change_method(record, field)
26
+ ["#{field}_changed?", "encrypted_#{field}_changed?"].each do |m|
27
+ return m.to_sym if record.respond_to?( m.to_sym )
28
+ end
29
+ end
30
+
23
31
  end
24
32
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kontoapi-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
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-03 00:00:00.000000000 Z
12
+ date: 2012-10-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -150,7 +150,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
150
150
  version: '0'
151
151
  segments:
152
152
  - 0
153
- hash: 2241815877486876219
153
+ hash: -1721407188267647934
154
154
  required_rubygems_version: !ruby/object:Gem::Requirement
155
155
  none: false
156
156
  requirements: