10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# 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
|