Class: Gamefic::Query::Ascendants

Inherits:
Base
  • Object
show all
Includes:
Subqueries
Defined in:
lib/gamefic/query/ascendants.rb

Overview

Query the subject’s parent and accessible grandparents.

Instance Attribute Summary

Attributes inherited from Base

#arguments

Instance Method Summary collapse

Methods included from Subqueries

subquery_accessible

Methods inherited from Base

#accept?, #bind, #filter, #initialize, #inspect, #name, plain, #precision, #select, span

Constructor Details

This class inherits a constructor from Gamefic::Query::Base

Instance Method Details

#span(subject) ⇒ Object



10
11
12
13
# File 'lib/gamefic/query/ascendants.rb', line 10

def span(subject)
  [subject.parent].tap { |result| result.push result.last.parent while result.last&.parent&.accessible&.include?(result.last) }
                  .compact
end