Sha256: 5339c362c3a1fd9ead65bdf14dae46799002746b4cf449f93bed7d52380ecfc2

Contents?: true

Size: 861 Bytes

Versions: 7

Compression:

Stored size: 861 Bytes

Contents

# frozen_string_literal: true

# Spree::Users maintain a list of the subscriptions associated with them
module SolidusSubscriptions
  module Spree
    module User
      module HaveManySubscriptions
        def self.prepended(base)
          base.has_many(
            :subscriptions,
            class_name: 'SolidusSubscriptions::Subscription',
            foreign_key: 'user_id'
          )

          base.accepts_nested_attributes_for :subscriptions
        end

        def subscriptions_attributes=(params)
          ::Spree::Deprecation.warn(
            'Creating or updating subscriptions through Spree::User nested attributes is deprecated. ' \
            'Please use subscriptions APIs directly.'
          )
          super
        end
      end
    end
  end
end

Spree.user_class.prepend(SolidusSubscriptions::Spree::User::HaveManySubscriptions)

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
solidus_subscriptions-2.0.2 app/decorators/models/solidus_subscriptions/spree/user/have_many_subscriptions.rb
solidus_subscriptions-2.0.1 app/decorators/models/solidus_subscriptions/spree/user/have_many_subscriptions.rb
solidus_subscriptions-2.0.0 app/decorators/models/solidus_subscriptions/spree/user/have_many_subscriptions.rb
solidus_subscriptions-1.1.0 app/decorators/models/solidus_subscriptions/spree/user/have_many_subscriptions.rb
solidus_subscriptions-1.0.1 app/decorators/models/solidus_subscriptions/spree/user/have_many_subscriptions.rb
solidus_subscriptions-1.0.0 app/decorators/models/solidus_subscriptions/spree/user/have_many_subscriptions.rb
solidus_subscriptions-1.0.0.rc1 app/decorators/models/solidus_subscriptions/spree/user/have_many_subscriptions.rb