Class: CMIS::Server
- Inherits:
-
Object
- Object
- CMIS::Server
- Defined in:
- lib/cmis/server.rb
Instance Method Summary collapse
- #connection ⇒ Object
- #execute!(params = {}, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ Server
constructor
A new instance of Server.
- #inspect ⇒ Object
- #repositories(opts = {}) ⇒ Object
- #repository(repository_id, opts = {}) ⇒ Object
- #repository?(repository_id) ⇒ Boolean
- #repository_by_name(repository_name, opts = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Server
Returns a new instance of Server.
3 4 5 |
# File 'lib/cmis/server.rb', line 3 def initialize( = {}) @options = .symbolize_keys end |
Instance Method Details
#connection ⇒ Object
7 8 9 |
# File 'lib/cmis/server.rb', line 7 def connection @connection ||= Connection.new(@options) end |
#execute!(params = {}, options = {}) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/cmis/server.rb', line 11 def execute!(params = {}, = {}) params.symbolize_keys! .symbolize_keys! query = .fetch(:query, {}) headers = .fetch(:headers, {}) connection.do_request(params, query, headers).body end |
#inspect ⇒ Object
47 48 49 |
# File 'lib/cmis/server.rb', line 47 def inspect "#{self.class}[#{@options[:service_url]}]" end |
#repositories(opts = {}) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/cmis/server.rb', line 21 def repositories(opts = {}) result = execute!({}, opts) result.values.map do |r| Repository.new(r, self) end end |
#repository(repository_id, opts = {}) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/cmis/server.rb', line 29 def repository(repository_id, opts = {}) result = execute!({ cmisselector: 'repositoryInfo', repositoryId: repository_id }, opts) Repository.new(result[repository_id], self) end |
#repository?(repository_id) ⇒ Boolean
40 41 42 43 44 45 |
# File 'lib/cmis/server.rb', line 40 def repository?(repository_id) repository(repository_id) true rescue Exceptions::ObjectNotFound false end |
#repository_by_name(repository_name, opts = {}) ⇒ Object
36 37 38 |
# File 'lib/cmis/server.rb', line 36 def repository_by_name(repository_name, opts = {}) repositories(opts).find { |r| r.name == repository_name } end |