Sha256: c9d11f1ee05659b94a338f30949f2c2673692c5b0ebf19b1ede497b91e36c259

Contents?: true

Size: 878 Bytes

Versions: 8

Compression:

Stored size: 878 Bytes

Contents

# frozen_string_literal: true

module Gamefic
  module Scope
    # The base class for a Scoped query's scope.
    #
    class Base
      attr_reader :context

      # @param [Gamefic::Entity]
      def initialize context
        @context = context
      end

      # @param [Array<Gamefic::Entity>]
      def matches
        []
      end

      # @param [Gamefic::Entity]
      def self.matches context
        new(context).matches
      end

      def self.precision
        0
      end

      private

      # Return an array of the entity's accessible descendants.
      #
      # @param [Entity]
      # @return [Array<Entity>]
      def subquery_accessible entity
        return [] unless entity&.accessible?

        entity.children.flat_map do |c|
          [c] + subquery_accessible(c)
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
gamefic-3.6.0 lib/gamefic/scope/base.rb
gamefic-3.5.0 lib/gamefic/scope/base.rb
gamefic-3.4.0 lib/gamefic/scope/base.rb
gamefic-3.3.0 lib/gamefic/scope/base.rb
gamefic-3.2.1 lib/gamefic/scope/base.rb
gamefic-3.2.0 lib/gamefic/scope/base.rb
gamefic-3.1.0 lib/gamefic/scope/base.rb
gamefic-3.0.0 lib/gamefic/scope/base.rb