Class: AllegroGraph::Catalog
- Inherits:
-
Object
- Object
- AllegroGraph::Catalog
- 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
-
#name ⇒ Object
Returns the value of attribute name.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #exists? ⇒ Boolean
-
#initialize(server, name, options = { }) ⇒ Catalog
constructor
A new instance of Catalog.
- #path ⇒ Object
- #repositories ⇒ Object
- #root? ⇒ Boolean
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, = { }) @server = server @name = name @root = [:root] || false end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
9 10 11 |
# File 'lib/allegro_graph/catalog.rb', line 9 def name @name end |
#server ⇒ Object (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
29 30 31 |
# File 'lib/allegro_graph/catalog.rb', line 29 def exists? @server.catalogs.include? self end |
#path ⇒ Object
21 22 23 |
# File 'lib/allegro_graph/catalog.rb', line 21 def path self.root? ? "" : "/catalogs/#{@name}" end |
#repositories ⇒ Object
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
25 26 27 |
# File 'lib/allegro_graph/catalog.rb', line 25 def root? !!@root end |