Class: Injector

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/greenlight/injector.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeInjector

Returns a new instance of Injector.



8
9
10
# File 'lib/greenlight/injector.rb', line 8

def initialize
  self.headers = {}
end

Instance Attribute Details

#headersObject

Returns the value of attribute headers.



6
7
8
# File 'lib/greenlight/injector.rb', line 6

def headers
  @headers
end

Class Method Details

.decorate(options) ⇒ Object



20
21
22
23
24
# File 'lib/greenlight/injector.rb', line 20

def self.decorate(options)
  options[:headers] = {} unless (options.key?(:headers) && options[:headers].is_a?(Hash))
  options[:headers].merge!(Injector.instance.headers)
  options
end

Instance Method Details

#add_header(header, value) ⇒ Object



12
13
14
# File 'lib/greenlight/injector.rb', line 12

def add_header(header, value)
  self.headers[header] = value
end

#rm_header(header) ⇒ Object



16
17
18
# File 'lib/greenlight/injector.rb', line 16

def rm_header(header)
  self.headers.delete(header)
end