Class: Distant::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/distant/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



6
7
8
9
10
# File 'lib/distant/config.rb', line 6

def initialize
  # Default just returns an empty hash:
  self.auth_header_generator = Proc.new{ {} }
  self.default_header_generator = Proc.new{ {} }
end

Instance Attribute Details

#auth_header_generatorObject

Returns the value of attribute auth_header_generator.



4
5
6
# File 'lib/distant/config.rb', line 4

def auth_header_generator
  @auth_header_generator
end

#base_uriObject

Returns the value of attribute base_uri.



4
5
6
# File 'lib/distant/config.rb', line 4

def base_uri
  @base_uri
end

#default_header_generatorObject

Returns the value of attribute default_header_generator.



4
5
6
# File 'lib/distant/config.rb', line 4

def default_header_generator
  @default_header_generator
end

Instance Method Details

#auth_headers(body = nil) ⇒ Object



26
27
28
# File 'lib/distant/config.rb', line 26

def auth_headers(body=nil)
  auth_header_generator.call(body)
end

#default_headers(body = nil) ⇒ Object



22
23
24
# File 'lib/distant/config.rb', line 22

def default_headers(body=nil)
  self.default_header_generator.call(body)
end

#set_authentication_headers_with(&block) ⇒ Object



12
13
14
15
# File 'lib/distant/config.rb', line 12

def set_authentication_headers_with(&block)
  raise ArgumentError.new 'block required' unless block_given?
  self.auth_header_generator = block
end

#set_default_headers_with(&block) ⇒ Object



17
18
19
20
# File 'lib/distant/config.rb', line 17

def set_default_headers_with(&block)
  raise ArgumentError.new 'block required' unless block_given?
  self.default_header_generator = block
end