Sha256: d20b31c02ca4923f359a882a5e1fb64e36f143bca73585307ce8b5e03190c065

Contents?: true

Size: 756 Bytes

Versions: 6

Compression:

Stored size: 756 Bytes

Contents

module JsonapiCompliable
  module Scoping
    class Base
      attr_reader :resource, :query_hash

      def initialize(resource, query_hash, scope)
        @query_hash = query_hash
        @resource   = resource
        @scope      = scope
      end

      def apply
        apply_standard_or_override
      end

      def apply_standard_or_override
        if apply_standard_scope?
          @scope = apply_standard_scope
        else
          @scope = apply_custom_scope
        end

        @scope
      end

      def apply_standard_scope?
        custom_scope.nil?
      end

      def apply_standard_scope
        raise 'override in subclass'
      end

      def apply_custom_scope
        raise 'override in subclass'
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
jsonapi_compliable-0.5.6 lib/jsonapi_compliable/scoping/base.rb
jsonapi_compliable-0.5.5 lib/jsonapi_compliable/scoping/base.rb
jsonapi_compliable-0.5.4 lib/jsonapi_compliable/scoping/base.rb
jsonapi_compliable-0.5.3 lib/jsonapi_compliable/scoping/base.rb
jsonapi_compliable-0.5.2 lib/jsonapi_compliable/scoping/base.rb
jsonapi_compliable-0.5.1 lib/jsonapi_compliable/scoping/base.rb