Class: HttpMonkey::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/http_monkey/configuration.rb

Defined Under Namespace

Classes: Behaviours, Middlewares

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



5
6
7
8
9
10
11
12
# File 'lib/http_monkey/configuration.rb', line 5

def initialize
  net_adapter(:net_http)  #default adapter
  @behaviours = HttpMonkey::Configuration::Behaviours.new
  # behaviour default always return response
  @behaviours.on_unknown { |client, req, response| response }
  @middlewares = HttpMonkey::Configuration::Middlewares.new
  @storage = Hash.new
end

Instance Method Details

#behaviours(&block) ⇒ Object



25
26
27
28
# File 'lib/http_monkey/configuration.rb', line 25

def behaviours(&block)
  @behaviours.instance_eval(&block) if block_given?
  @behaviours
end

#initialize_copy(source) ⇒ Object



14
15
16
17
18
# File 'lib/http_monkey/configuration.rb', line 14

def initialize_copy(source)
  super
  @behaviours = @behaviours.clone
  @middlewares = @middlewares.clone
end

#middlewares(&block) ⇒ Object



30
31
32
33
# File 'lib/http_monkey/configuration.rb', line 30

def middlewares(&block)
  @middlewares.instance_eval(&block) if block_given?
  @middlewares
end

#net_adapter(adapter = nil) ⇒ Object



20
21
22
23
# File 'lib/http_monkey/configuration.rb', line 20

def net_adapter(adapter = nil)
  @net_adapter = adapter unless adapter.nil?
  @net_adapter
end

#storage(store = nil) ⇒ Object



35
36
37
38
# File 'lib/http_monkey/configuration.rb', line 35

def storage(store = nil)
  @storage = store unless store.nil?
  @storage
end