class Gamefic::Scope::Base

The base class for a Scoped query’s scope.

Attributes

context[R]

Public Class Methods

matches(context) click to toggle source

@param [Gamefic::Entity]

# File lib/gamefic/scope/base.rb, line 21
def self.matches context
  new(context).matches
end
new(context) click to toggle source

@param [Gamefic::Entity]

# File lib/gamefic/scope/base.rb, line 11
def initialize context
  @context = context
end
precision() click to toggle source
# File lib/gamefic/scope/base.rb, line 25
def self.precision
  0
end

Public Instance Methods

matches() click to toggle source

@param [Array<Gamefic::Entity>]

# File lib/gamefic/scope/base.rb, line 16
def matches
  []
end

Private Instance Methods

subquery_accessible(entity) click to toggle source

Return an array of the entity’s accessible descendants.

@param [Entity] @return [Array<Entity>]

# File lib/gamefic/scope/base.rb, line 35
def subquery_accessible entity
  return [] unless entity&.accessible?

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