Sha256: a44fdc2107faed02f44b51ad71f84ab6f0ab1106a465698a9769c41f3421e0d9

Contents?: true

Size: 601 Bytes

Versions: 3

Compression:

Stored size: 601 Bytes

Contents

module JsonapiCompliable
  module Util
    class Scoping
      def self.apply?(controller, object, force)
        return false if force == false
        return true if controller._jsonapi_scope.nil? && object.is_a?(ActiveRecord::Relation)

        already_scoped = !!controller._jsonapi_scope
        is_activerecord = object.is_a?(ActiveRecord::Base)
        is_activerecord_array = object.is_a?(Array) && object[0].is_a?(ActiveRecord::Base)

        if [already_scoped, is_activerecord, is_activerecord_array].any?
          false
        else
          true
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
jsonapi_compliable-0.4.0 lib/jsonapi_compliable/util/scoping.rb
jsonapi_compliable-0.3.10 lib/jsonapi_compliable/util/scoping.rb
jsonapi_compliable-0.3.9 lib/jsonapi_compliable/util/scoping.rb