Class: ActiveTriples::ParentStrategy::Ancestors
- Inherits:
-
Object
- Object
- ActiveTriples::ParentStrategy::Ancestors
- Includes:
- Enumerable
- Defined in:
- lib/active_triples/persistence_strategies/parent_strategy.rb
Overview
An enumerable over the ancestors of an resource
Instance Attribute Summary collapse
-
#source ⇒ Object
Returns the value of attribute source.
Instance Method Summary collapse
- #each {|RDFSource| ... } ⇒ Enumerator<RDFSource>
-
#initialize(source) ⇒ Ancestors
constructor
A new instance of Ancestors.
Constructor Details
#initialize(source) ⇒ Ancestors
Returns a new instance of Ancestors.
145 146 147 |
# File 'lib/active_triples/persistence_strategies/parent_strategy.rb', line 145 def initialize(source) @source = source end |
Instance Attribute Details
#source ⇒ Object
Returns the value of attribute source.
141 142 143 |
# File 'lib/active_triples/persistence_strategies/parent_strategy.rb', line 141 def source @source end |
Instance Method Details
#each {|RDFSource| ... } ⇒ Enumerator<RDFSource>
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/active_triples/persistence_strategies/parent_strategy.rb', line 154 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 |