Class: Sequencescape::Api::ConnectionFactory

Inherits:
Object
  • Object
show all
Includes:
Actions
Defined in:
lib/sequencescape-api/connection_factory.rb

Defined Under Namespace

Modules: Actions, Helpers

Constant Summary

ConnectionError =
Class.new(::Sequencescape::Api::Error)

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Actions

#has_create_action, #has_update_action

Constructor Details

#initialize(options) ⇒ ConnectionFactory



23
24
25
# File 'lib/sequencescape-api/connection_factory.rb', line 23

def initialize(options)
  @url, @cookie, @authorisation = options[:url], options[:cookie], options[:authorisation]
end

Class Method Details

.create(options) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/sequencescape-api/connection_factory.rb', line 8

def self.create(options)
  required_options = [ :cookie ]
  required_options.push(:url) if self.default_url.blank?
  required_options.push(:allow_blank => false)
  options.required!(*required_options) do |missing|
    raise ::Sequencescape::Api::Error, "No #{missing.or_sentence} set"
  end

  options[:url] ||= self.default_url
  new(options)
end

Instance Method Details

#url_for_uuid(uuid) ⇒ Object



28
29
30
# File 'lib/sequencescape-api/connection_factory.rb', line 28

def url_for_uuid(uuid)
  URI.join(url, uuid).to_s
end