Class: Gamefic::Scope::Family

Inherits:
Base
  • Object
show all
Defined in:
lib/gamefic/scope/family.rb

Overview

The Family scope returns an entity’s parent, siblings, and descendants.

Instance Attribute Summary

Attributes inherited from Base

#context

Instance Method Summary collapse

Methods inherited from Base

#initialize, matches, precision

Constructor Details

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

Instance Method Details

#matchesObject



8
9
10
11
12
13
14
15
16
17
# File 'lib/gamefic/scope/family.rb', line 8

def matches
  result = context.parent ? [context.parent] : []
  result.concat subquery_accessible(context.parent)
  result.delete context
  context.children.each do |c|
    result.push c
    result.concat subquery_accessible(c)
  end
  result.uniq
end