Module: PubliSci::Prov::Dereferencable

Included in:
Activity::Associations, Activity::Generations, Activity::Usages, Entity::Derivations
Defined in:
lib/bio-publisci/mixins/dereferencable.rb

Instance Method Summary collapse

Instance Method Details

#[](index) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/bio-publisci/mixins/dereferencable.rb', line 19

def [](index)
  self.dereference.fetch(index)
  # if self.fetch(index).is_a? Symbol
  #   raise "UnknownEntity: #{self.fetch(index)}" unless Prov.entities[self.fetch(index)]
  #   Prov.entities[self.fetch(index)]
  # else
  #   self.fetch(index)
  # end
end

#dereferenceObject



4
5
6
7
8
9
10
11
12
13
# File 'lib/bio-publisci/mixins/dereferencable.rb', line 4

def dereference
  self.map{|x|
    if x.is_a? Symbol
      raise "Unknown#{method.capitalize}: #{x}" unless Prov.registry[method.to_sym][x]
      Prov.registry[method.to_sym][x]
    else
      x
    end
  }
end

#map_(&blk) ⇒ Object



29
30
31
# File 'lib/bio-publisci/mixins/dereferencable.rb', line 29

def map_(&blk)
  self.dereference.map(&blk)
end

#methodObject



15
16
17
# File 'lib/bio-publisci/mixins/dereferencable.rb', line 15

def method
  raise "must be overridden"
end