Sha256: b2119f6e5df300c57f2a72d0af43ee45961b0fb5d38d38635754dce793a8cf5b

Contents?: true

Size: 787 Bytes

Versions: 1

Compression:

Stored size: 787 Bytes

Contents

module PubliSci
  module Prov
    module Dereferencable
      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

      def method
        raise "must be overridden"
      end

      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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bio-publisci-0.0.6 lib/bio-publisci/mixins/dereferencable.rb