Class: SolidusSubscriptions::PermissionSets::DefaultCustomer

Inherits:
Spree::PermissionSets::Base
  • Object
show all
Defined in:
lib/solidus_subscriptions/permission_sets/default_customer.rb

Instance Method Summary collapse

Instance Method Details

#activate!Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/solidus_subscriptions/permission_sets/default_customer.rb', line 6

def activate!
  can [:show, :display, :update, :skip, :cancel, :pause, :resume], Subscription, ['user_id = ?', user.id] do |subscription, guest_token|
    (subscription.guest_token.present? && subscription.guest_token == guest_token) ||
      (subscription.user && subscription.user == user)
  end

  can [:show, :display, :update, :destroy], LineItem do |line_item, guest_token|
    (line_item.subscription&.guest_token.present? && line_item.subscription.guest_token == guest_token) ||
      (line_item.subscription&.user && line_item.subscription.user == user)
  end
end