Sha256: 717e7b1c974386c572e3ad03353f3e0d3862e9a70ae625c04b52ad1e7c9aa2d5
Contents?: true
Size: 991 Bytes
Versions: 1
Compression:
Stored size: 991 Bytes
Contents
module WepayRails module Helpers module ModelHelpers # Create a column on one of your models where the wepay authorization code # will be stored to be used for future transactions. Example: # add_column :users, :wepay_auth_code, :string # Then in your model, let's say the User model, you tell wepay-rails what the column name is: # # class User < ActiveRecord::Base # wepayable :wepay_auth_code # end def wepayable(*args) @params = args.last if args.last.is_a?(Hash) @column = args.first.to_s File.open('/tmp/noisebytes.log','a') {|f| f.write("Args are #{args.inspect}\n")} File.open('/tmp/noisebytes.log','a') {|f| f.write("Column is #{@column}\n")} define_method "has_#{@column}?" do "self.#{@column}.present?" end define_method "save_#{@column}" do |value| "self.update_attribute(#{@column}, #{value})" end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
wepay-rails-0.1.51 | lib/helpers/model_helpers.rb |