Class: FDB::Internal::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/fdbdirectory.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(subspace, path, target_path) ⇒ Node

Returns a new instance of Node.



645
646
647
648
649
650
# File 'lib/fdbdirectory.rb', line 645

def initialize(subspace, path, target_path)
  @subspace = subspace
  @path = path
  @target_path = target_path
  @layer = nil
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



653
654
655
# File 'lib/fdbdirectory.rb', line 653

def path
  @path
end

#subspaceObject (readonly)

Returns the value of attribute subspace.



652
653
654
# File 'lib/fdbdirectory.rb', line 652

def subspace
  @subspace
end

Instance Method Details

#exists?Boolean

Returns:

  • (Boolean)


655
656
657
# File 'lib/fdbdirectory.rb', line 655

def exists?
  !@subspace.nil?
end

#get_contents(directory_layer, tr = nil) ⇒ Object



684
685
686
# File 'lib/fdbdirectory.rb', line 684

def get_contents(directory_layer, tr=nil)
  directory_layer.send(:contents_of_node, @subspace, @path, layer(tr))
end

#get_partition_subpath(tr = nil) ⇒ Object



680
681
682
# File 'lib/fdbdirectory.rb', line 680

def get_partition_subpath(tr=nil)
  @target_path[@path.length..-1]
end

#is_in_partition?(tr = nil, include_empty_subpath = false) ⇒ Boolean

Returns:

  • (Boolean)


674
675
676
677
678
# File 'lib/fdbdirectory.rb', line 674

def is_in_partition?(tr=nil, include_empty_subpath=false)
  exists? && 
    @layer == 'partition' && 
    (include_empty_subpath || @path.length < @target_path.length)
end

#layer(tr = nil) ⇒ Object



664
665
666
667
668
669
670
671
672
# File 'lib/fdbdirectory.rb', line 664

def layer(tr=nil)
  if tr
    @layer = tr[@subspace['layer']]
  else
    raise 'Layer has not been read' unless @layer
  end

  @layer
end

#prefetch_metadata(tr) ⇒ Object



659
660
661
662
# File 'lib/fdbdirectory.rb', line 659

def (tr)
  layer(tr) if exists?
  self
end