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
11
# 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{ {} }
  self.debug = false
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

#debugObject

Returns the value of attribute debug.



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

def debug
  @debug
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



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

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

#default_headers(body = nil) ⇒ Object



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

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

#set_authentication_headers_with(&block) ⇒ Object



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

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



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

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