diff --git a/Gemfile.lock b/Gemfile.lock index f536c3a..ea28b05 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -42,7 +42,7 @@ GEM rake rdoc journey (1.0.4) - json (1.7.4) + json (1.8.3) kontoapi-ruby (0.2.0) addressable yajl-ruby @@ -112,3 +112,6 @@ DEPENDENCIES rails (>= 3.0.0) rspec (>= 2.3.0) simplecov + +BUNDLED WITH + 1.12.5 diff --git a/README.markdown b/README.markdown index 0becf28..a5a2ee5 100644 --- a/README.markdown +++ b/README.markdown @@ -18,10 +18,11 @@ USAGE Add an initializer (e.g. kontoapi.rb) in `config/initializers`: KontoAPI.setup do |config| - # mendatory + # mandatory config.api_key = '' # get one at https://www.kontoapi.de/ # optional (with defaults) config.timeout = 10 + config.disable_for = ['development', 'test'] end Then, in one of the models you want to validate bank account data with: diff --git a/VERSION b/VERSION index 28af839..a53741c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2.5 \ No newline at end of file +0.2.6 \ No newline at end of file diff --git a/lib/kontoapi-rails/config.rb b/lib/kontoapi-rails/config.rb index 925f053..2cf1498 100644 --- a/lib/kontoapi-rails/config.rb +++ b/lib/kontoapi-rails/config.rb @@ -2,6 +2,8 @@ module KontoAPI module Config + @@disable_for = ['development', 'test'] + class << self def api_key=(new_key) @@ -12,6 +14,14 @@ def timeout=(new_timeout) KontoAPI::timeout = new_timeout end + def disable_for + @@disable_for + end + + def disable_for=(disable_for) + @@disable_for = disable_for + end + end end diff --git a/lib/kontoapi-rails/orm/active_record_extension.rb b/lib/kontoapi-rails/orm/active_record_extension.rb index c53cd53..7504458 100644 --- a/lib/kontoapi-rails/orm/active_record_extension.rb +++ b/lib/kontoapi-rails/orm/active_record_extension.rb @@ -7,6 +7,7 @@ def self.included(base) module ClassMethods def validates_bank_account(options={}) + return if KontoAPI::Config.disable_for.include?(::Rails.env) options.symbolize_keys! options.reverse_merge!( :account_number_field => :account_number, @@ -18,6 +19,7 @@ def validates_bank_account(options={}) end def autocomplete_bank_name(options={}) + return if KontoAPI::Config.disable_for.include?(::Rails.env) options.symbolize_keys! options.reverse_merge!( :bank_code_field => :bank_code, @@ -46,6 +48,7 @@ def autocomplete_bank_name(options={}) end def validates_iban(field, options={}) + return if KontoAPI::Config.disable_for.include?(::Rails.env) options.symbolize_keys! options.reverse_merge!( :allow_nil => true, :on_timeout => :ignore ) define_method :iban_validation do @@ -68,6 +71,7 @@ def validates_iban(field, options={}) end def validates_bic(field, options={}) + return if KontoAPI::Config.disable_for.include?(::Rails.env) options.symbolize_keys! options.reverse_merge!( :allow_nil => true, :on_timeout => :ignore ) define_method :bic_validation do diff --git a/lib/kontoapi-rails/railtie.rb b/lib/kontoapi-rails/railtie.rb index 2f109d3..b3131f5 100644 --- a/lib/kontoapi-rails/railtie.rb +++ b/lib/kontoapi-rails/railtie.rb @@ -13,8 +13,6 @@ class Railtie < ::Rails::Railtie #:nodoc: end if defined? ::Mongoid require File.join(File.dirname(__FILE__), 'orm/mongoid_extension') - #::Mongoid::Document.send :include, KontoAPI::MongoidExtension::Document - #::Mongoid::Criteria.send :include, KontoAPI::MongoidExtension::Criteria end end end