Sha256: 31fd879a13a921b16336d647ba28b17fee05390a1181a4946647b9b701d93243

Contents?: true

Size: 504 Bytes

Versions: 1

Compression:

Stored size: 504 Bytes

Contents

module SolidusSubscriptions
  class Ability
    include CanCan::Ability

    def initialize(user)
      alias_action :create, :read, :update, :destroy, to: :crud

      if user.has_spree_role?('admin')
        can(:manage, LineItem)
        can(:manage, Subscription)
      else
        can([:crud, :skip, :cancel], Subscription, user_id: user.id)
        can(:crud, LineItem) do |li, order|
          li.order.user == user || li.order == order
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
solidus_subscriptions-alpha-0.0.4 lib/solidus_subscriptions/ability.rb