module Billing::Billable::ClassMethods
Public Instance Methods
has_billing(options={})
click to toggle source
# File lib/billing/billable.rb, line 10 def has_billing(options={}) payment_types_scope = options.delete(:payment_types) has_many :billing_bills, options.merge(as: :billable).reverse_merge(class_name: 'Billing::Bill') provide_billing_items(:billing_bills) if options[:as] has_many options[:as], options.merge(as: :billable).reverse_merge(class_name: 'Billing::Bill') provide_billing_items(options[:as]) end if payment_types_scope.present? if payment_types_scope.respond_to? :scope define_method :billing_payment_types do payment_types_scope end else alias_method :billing_payment_types, payment_types_scope.intern end end end
Private Instance Methods
provide_billing_items(association_name)
click to toggle source
# File lib/billing/billable.rb, line 30 def provide_billing_items(association_name) has_many "#{association_name}_charges".intern, class_name: 'Billing::Charge', through: association_name, source: :charges has_many "#{association_name}_payments".intern, class_name: 'Billing::Payment', through: association_name, source: :payments end