class Gamefic::Scope::Family
The Family
scope returns an entity’s ascendants, descendants, siblings, and siblings’ descendants.
Public Instance Methods
matches()
click to toggle source
# File lib/gamefic/scope/family.rb, line 9 def matches match_ascendants + match_descendants + match_siblings end
Private Instance Methods
match_ascendants()
click to toggle source
# File lib/gamefic/scope/family.rb, line 15 def match_ascendants [].tap do |result| here = context.parent while here result.push here here = here.parent end end end
match_descendants()
click to toggle source
# File lib/gamefic/scope/family.rb, line 25 def match_descendants context.children.flat_map do |child| [child] + subquery_accessible(child) end end
match_siblings()
click to toggle source
# File lib/gamefic/scope/family.rb, line 31 def match_siblings return [] unless context.parent context.parent .children .that_are_not(context) .flat_map do |child| [child] + subquery_accessible(child) end end