class Bodhi::Context
Attributes
connection[R]
credentials[R]
credentials_header[R]
credentials_type[R]
namespace[R]
server[R]
Public Class Methods
global_context()
click to toggle source
# File lib/bodhi-slam/context.rb, line 9 def self.global_context @@current_context ||= Bodhi::Context.new end
global_context=(context)
click to toggle source
# File lib/bodhi-slam/context.rb, line 13 def self.global_context=(context) @@current_context = context end
new(params={})
click to toggle source
# File lib/bodhi-slam/context.rb, line 17 def initialize(params={}) @connection = Faraday.new(url: params[:server]) do |faraday| faraday.use :http_cache faraday.request :multipart faraday.request :url_encoded faraday.adapter :net_http_persistent #faraday.adapter Faraday.default_adapter faraday.response :json, :content_type => /\bjson$/ #faraday.response :logger end @server = params[:server] @namespace = params[:namespace] if params[:cookie] @credentials = params[:cookie] @credentials_header = "Cookie" @credentials_type = "HTTP_COOKIE" else @credentials = @connection.basic_auth params[:username], params[:password] @credentials_header = "Authorization" @credentials_type = "HTTP_BASIC" end end
Public Instance Methods
attributes()
click to toggle source
# File lib/bodhi-slam/context.rb, line 44 def attributes attributes = Hash.new self.instance_variables.each do |variable| attribute_name = variable.to_s.delete('@').to_sym attributes[attribute_name] = send(attribute_name) end attributes end