Sha256: 94c7b76636613c542627e276214385ac4f8f6e991d149771c19d577139786d05

Contents?: true

Size: 583 Bytes

Versions: 3

Compression:

Stored size: 583 Bytes

Contents

module ActiveModel
  class Serializer
    module CanCan
      module ReflectionValue
        def value(serializer, include_slice)
          val = super(serializer, include_slice)
          unless authorize?
            return val
          end
          if val.kind_of?(Array)
            val.select do |item|
              serializer.current_ability.can?(:read, item)
            end
          else
            if serializer.current_ability.can?(:read, val)
              val
            else
              nil
            end
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
active_model_serializers_cancancan-0.5.0 lib/active_model_serializers/cancan/reflection_value.rb
active_model_serializers_cancancan-0.4.0 lib/active_model_serializers/cancan/reflection_value.rb
active_model_serializers_cancancan-0.3.0 lib/active_model_serializers/cancan/reflection_value.rb