module Accountability::Extensions::ActsAsOfferable
Public Instance Methods
has_offerable(category = name, **options) { |offerable_category| ... }
click to toggle source
# File lib/accountability/extensions/acts_as_offerable.rb, line 7 def has_offerable(category = name, **options) tenants = options.values_at(:tenants, :tenant) tenants.append(:default) if tenants.empty? tenants.each do |tenant| offerable_category = Offerable.add(category, tenant: tenant, class_name: name) yield offerable_category if block_given? end self.acts_as = acts_as.dup << :offerable if reflections['price_overrides'].blank? has_many :price_overrides, class_name: 'Accountability::PriceOverride', as: :offerable_source, dependent: :destroy end end
has_offerable_trait(trait_name, **options) { |offerable_category| ... }
click to toggle source
# File lib/accountability/extensions/acts_as_offerable.rb, line 26 def has_offerable_trait(trait_name, **options) tenants = options.values_at(:tenants, :tenant) tenants.append(:default) if tenants.empty? category = options[:category].presence || trait_name tenants.each do |tenant| offerable_category = Offerable.add(category, tenant: tenant, trait: trait_name, class_name: name) yield offerable_category if block_given? end self.acts_as = acts_as.dup << :offerable end