Sha256: 2711a91b7709449582335a4c8ff4dac2449c69deed91854fc1356f076a9d2a60
Contents?: true
Size: 963 Bytes
Versions: 1
Compression:
Stored size: 963 Bytes
Contents
module KontoAPI module ActiveRecordExtension def self.included(base) base.send(:extend, ClassMethods) end module ClassMethods def validates_bank_account(options={}) options.symbolize_keys! validates_with KontoAPI::BankAccountValidator, options end def autocomplete_bank_name(options={}) options.symbolize_keys! options.reverse_merge!( :bank_code_field => :bank_code, :bank_name_field => :bank_name ) #write_inheritable_attribute(:autocomplete_bank_name_options, options) define_method :autocomplete_bank_name do current_value = send(:"#{options[:bank_name_field]}") blz = send(:"#{options[:bank_code_field]}") self.send(:"#{options[:bank_name_field]}=", KontoAPI::bank_name(blz)) if current_value.blank? && blz.present? end before_save :autocomplete_bank_name end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
kontoapi-rails-0.0.1 | lib/kontoapi-rails/orm/active_record_extension.rb |