Sha256: a5ed563de327d06f1871e40ab58cb1caa9085e0b0e42da52c8a8683b1dabc5b8

Contents?: true

Size: 818 Bytes

Versions: 8

Compression:

Stored size: 818 Bytes

Contents

module JsonapiCompliable
  module Scope
    class Base
      attr_reader :controller, :dsl, :params, :scope

      def initialize(controller, scope)
        @controller = controller
        @dsl        = controller._jsonapi_compliable
        @params     = controller.params
        @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

8 entries across 8 versions & 1 rubygems

Version Path
jsonapi_compliable-0.4.0 lib/jsonapi_compliable/scope/base.rb
jsonapi_compliable-0.3.10 lib/jsonapi_compliable/scope/base.rb
jsonapi_compliable-0.3.9 lib/jsonapi_compliable/scope/base.rb
jsonapi_compliable-0.3.8 lib/jsonapi_compliable/scope/base.rb
jsonapi_compliable-0.3.7 lib/jsonapi_compliable/scope/base.rb
jsonapi_compliable-0.3.6 lib/jsonapi_compliable/scope/base.rb
jsonapi_compliable-0.3.5 lib/jsonapi_compliable/scope/base.rb
jsonapi_compliable-0.3.4 lib/jsonapi_compliable/scope/base.rb