Sha256: 686fb6821709fcbed8b2e94946bebdfa1f5bdd26a133e5e7b7a3427fc392c398

Contents?: true

Size: 501 Bytes

Versions: 3

Compression:

Stored size: 501 Bytes

Contents

module ActiveModel
  class Serializer
    module CanCan
      module Helpers
        def current_ability
          Ability.new(instance_options[:scope])
        end

        def current_user
          instance_options[:scope]
        end

        def can?(*args)
          current_ability.can? *args
        end

        def cannot?(*args)
          current_ability.cannot? *args
        end
      end
    end
  end
end

ActiveModel::Serializer.send :include, ActiveModel::Serializer::CanCan::Helpers

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
active_model_serializers_cancancan-0.3.0 lib/active_model_serializers/cancan/helpers.rb
active_model_serializers_cancancan-0.2.0 lib/active_model_serializers/cancan/helpers.rb
active_model_serializers_cancancan-0.1.1 lib/active_model_serializers/cancan/helpers.rb