Class: CMIS::Server

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

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Server

Returns a new instance of Server.



3
4
5
# File 'lib/cmis/server.rb', line 3

def initialize(options = {})
  @options = options.symbolize_keys
end

Instance Method Details

#connectionObject



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 = {}, options = {})
  params.symbolize_keys!

  options.symbolize_keys!
  query = options.fetch(:query, {})
  headers = options.fetch(:headers, {})

  connection.do_request(params, query, headers).body
end

#inspectObject



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

Returns:

  • (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