Sha256: 5362660ca5e0e796b8fde82ddc3d7627be41a7f4f455270c51b47cef072bb9b8

Contents?: true

Size: 901 Bytes

Versions: 93

Compression:

Stored size: 901 Bytes

Contents

# Mostly for the callbacks

module ActsAsPurchasableParent
  extend ActiveSupport::Concern

  module Base
    def acts_as_purchasable_parent(*options)
      @acts_as_purchasable_parent = options || []
      include ::ActsAsPurchasableParent
    end
  end

  module ClassMethods
    def acts_as_purchasable_parent?; true; end

    def before_purchase(&block)
      send :define_method, :before_purchase do |order| self.instance_exec(order, &block) end
    end

    def after_purchase(&block)
      send :define_method, :after_purchase do |order| self.instance_exec(order, &block) end
    end

    def after_decline(&block)
      send :define_method, :after_decline do |order| self.instance_exec(order, &block) end
    end
  end

  included do
    has_many :orders, -> { order(:id) }, as: :parent, class_name: 'Effective::Order', dependent: :nullify
    accepts_nested_attributes_for :orders
  end

end

Version data entries

93 entries across 93 versions & 1 rubygems

Version Path
effective_orders-6.9.10 app/models/concerns/acts_as_purchasable_parent.rb
effective_orders-6.9.9 app/models/concerns/acts_as_purchasable_parent.rb
effective_orders-6.9.8 app/models/concerns/acts_as_purchasable_parent.rb
effective_orders-6.9.7 app/models/concerns/acts_as_purchasable_parent.rb
effective_orders-6.9.6 app/models/concerns/acts_as_purchasable_parent.rb
effective_orders-6.9.5 app/models/concerns/acts_as_purchasable_parent.rb
effective_orders-6.9.4 app/models/concerns/acts_as_purchasable_parent.rb
effective_orders-6.9.2 app/models/concerns/acts_as_purchasable_parent.rb
effective_orders-6.9.1 app/models/concerns/acts_as_purchasable_parent.rb
effective_orders-6.9.0 app/models/concerns/acts_as_purchasable_parent.rb
effective_orders-6.8.2 app/models/concerns/acts_as_purchasable_parent.rb
effective_orders-6.8.1 app/models/concerns/acts_as_purchasable_parent.rb
effective_orders-6.8.0 app/models/concerns/acts_as_purchasable_parent.rb
effective_orders-6.7.3 app/models/concerns/acts_as_purchasable_parent.rb
effective_orders-6.7.2 app/models/concerns/acts_as_purchasable_parent.rb
effective_orders-6.7.1 app/models/concerns/acts_as_purchasable_parent.rb
effective_orders-6.7.0 app/models/concerns/acts_as_purchasable_parent.rb
effective_orders-6.6.3 app/models/concerns/acts_as_purchasable_parent.rb
effective_orders-6.6.2 app/models/concerns/acts_as_purchasable_parent.rb
effective_orders-6.6.1 app/models/concerns/acts_as_purchasable_parent.rb