Class: CMIS::Connection
- Inherits:
-
Object
- Object
- CMIS::Connection
- Defined in:
- lib/cmis/connection.rb
Instance Method Summary collapse
- #execute!(params = {}, options = {}) ⇒ Object
-
#initialize(options) ⇒ Connection
constructor
A new instance of Connection.
Constructor Details
#initialize(options) ⇒ Connection
Returns a new instance of Connection.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/cmis/connection.rb', line 3 def initialize() .symbolize_keys! service_url = [:service_url] || ENV['CMIS_BROWSER_URL'] @service_url = service_url or raise "\ option `:service_url` or ENV['CMIS_BROWSER_URL'] must be set" adapter = ([:adapter] || :net_http).to_sym headers = { user_agent: "cmis-ruby/#{VERSION} [#{adapter}]" }.merge([:headers] || {}) conn_opts = { headers: headers, ssl: [:ssl] }.compact @http = Faraday.new(conn_opts) do |builder| builder.use RequestModifier builder.request :multipart builder.request :url_encoded if username = [:username] || ENV['CMIS_USER'] password = [:password] || ENV['CMIS_PASSWORD'] builder.basic_auth(username, password) end builder.adapter adapter builder.response :logger if [:log_requests] builder.use ResponseParser end @url_cache = {} end |
Instance Method Details
#execute!(params = {}, options = {}) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/cmis/connection.rb', line 35 def execute!(params = {}, = {}) .symbolize_keys! query = [:query] || {} headers = [:headers]|| {} url = url(params.delete(:repositoryId), params[:objectId]) response = if params[:cmisaction] @http.post(url, params, headers) else @http.get(url, params.merge(query), headers) end response.body end |