class ActiveTriples::ParentStrategy::Ancestors
An enumerable over the ancestors of an resource
Attributes
source[R]
@!attribute source
@return [RDFSource]
Public Class Methods
new(source)
click to toggle source
@param source [RDFSource]
# File lib/active_triples/persistence_strategies/parent_strategy.rb, line 146 def initialize(source) @source = source end
Public Instance Methods
each() { |current| ... }
click to toggle source
@yield [RDFSource] gives each ancestor to the block @return [Enumerator<RDFSource>]
@raise [NilParentError] if ‘source` does not persist to a parent
# File lib/active_triples/persistence_strategies/parent_strategy.rb, line 155 def each raise NilParentError if !source.persistence_strategy.respond_to?(:parent) || source.persistence_strategy.parent.nil? current = source.persistence_strategy.parent if block_given? loop do yield current break unless (current.persistence_strategy.respond_to?(:parent) && current.persistence_strategy.parent) break if current.persistence_strategy.parent == current current = current.persistence_strategy.parent end end to_enum end