Class: AllegroGraph::Catalog

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

Overview

The Catalog class wrap the corresponding resource on the AllegroGraph server. A catalog can hold many repositories.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server, name, options = { }) ⇒ Catalog

Returns a new instance of Catalog.



11
12
13
14
15
# File 'lib/allegro_graph/catalog.rb', line 11

def initialize(server, name, options = { })
  @server = server
  @name = name
  @root = options[:root] || false
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



9
10
11
# File 'lib/allegro_graph/catalog.rb', line 9

def name
  @name
end

#serverObject (readonly)

Returns the value of attribute server.



8
9
10
# File 'lib/allegro_graph/catalog.rb', line 8

def server
  @server
end

Instance Method Details

#==(other) ⇒ Object



17
18
19
# File 'lib/allegro_graph/catalog.rb', line 17

def ==(other)
  other.is_a?(self.class) && self.server == other.server && self.root? == other.root? && self.name == other.name
end

#exists?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/allegro_graph/catalog.rb', line 29

def exists?
  @server.catalogs.include? self
end

#pathObject



21
22
23
# File 'lib/allegro_graph/catalog.rb', line 21

def path
  self.root? ? "" : "/catalogs/#{@name}"
end

#repositoriesObject



33
34
35
36
# File 'lib/allegro_graph/catalog.rb', line 33

def repositories
  repositories = @server.request :get, self.path + "/repositories", :expected_status_code => 200
  repositories.map { |repository| Repository.new self, repository["id"] }
end

#root?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/allegro_graph/catalog.rb', line 25

def root?
  !!@root
end