Module: Cassette

Extended by:
Cassette
Included in:
Cassette
Defined in:
lib/cassette.rb,
lib/cassette/cache.rb,
lib/cassette/client.rb,
lib/cassette/errors.rb,
lib/cassette/rubycas.rb,
lib/cassette/version.rb,
lib/cassette/authentication.rb,
lib/cassette/rubycas/helper.rb,
lib/cassette/errors/not_a_customer.rb,
lib/cassette/errors/not_an_employee.rb,
lib/cassette/rubycas/single_sign_out_constraint.rb,
lib/cassette/rubycas/not_single_sign_out_constraint.rb

Defined Under Namespace

Modules: Cache, Errors, Rubycas Classes: Authentication, Client, Version

Constant Summary collapse

DEFAULT_TIMEOUT =
10

Instance Method Summary collapse

Instance Method Details

#configObject



35
36
37
38
39
# File 'lib/cassette.rb', line 35

def config
  if defined?(@@config)
    @@config
  end
end

#config=(config) ⇒ Object



41
42
43
# File 'lib/cassette.rb', line 41

def config=(config)
  @@config = config
end

#get(uri, payload, timeout = DEFAULT_TIMEOUT) ⇒ Object



52
53
54
55
56
57
# File 'lib/cassette.rb', line 52

def get(uri, payload, timeout = DEFAULT_TIMEOUT)
  perform(:get, uri, payload, timeout) do |req|
    req.params = payload
    logger.debug "Request: #{req.inspect}"
  end
end

#loggerObject



21
22
23
24
25
26
27
28
29
# File 'lib/cassette.rb', line 21

def logger
  @@logger ||= begin
    if defined?(Rails) && Rails.logger
      Rails.logger
    else
      Logger.new("/dev/null")
    end
  end
end

#logger=(logger) ⇒ Object



31
32
33
# File 'lib/cassette.rb', line 31

def logger=(logger)
  @@logger = logger
end

#new_request(uri, timeout) ⇒ Object



45
46
47
48
49
50
# File 'lib/cassette.rb', line 45

def new_request(uri, timeout)
  Faraday.new(url: uri, ssl: { verify: false, version: "TLSv1" }) do |builder|
    builder.adapter :httpclient
    builder.options.timeout = timeout
  end
end

#post(uri, payload, timeout = DEFAULT_TIMEOUT) ⇒ Object



59
60
61
62
63
64
# File 'lib/cassette.rb', line 59

def post(uri, payload, timeout = DEFAULT_TIMEOUT)
  perform(:post, uri, payload, timeout) do |req|
    req.body = payload
    logger.debug "Request: #{req.inspect}"
  end
end