Class: Ethon::Easy::Mirror

Inherits:
Object
  • Object
show all
Defined in:
lib/ethon/easy/mirror.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Mirror

Returns a new instance of Mirror.



24
25
26
# File 'lib/ethon/easy/mirror.rb', line 24

def initialize(options = {})
  @options = options
end

Instance Attribute Details

#optionsObject (readonly) Also known as: to_hash

Returns the value of attribute options.



4
5
6
# File 'lib/ethon/easy/mirror.rb', line 4

def options
  @options
end

Class Method Details

.from_easy(easy) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/ethon/easy/mirror.rb', line 16

def self.from_easy(easy)
  options = {}
  informations_to_mirror.each do |info|
    options[info] = easy.send(info)
  end
  new(options)
end

.informations_to_logObject



12
13
14
# File 'lib/ethon/easy/mirror.rb', line 12

def self.informations_to_log
  [:url, :response_code, :return_code, :total_time]
end

.informations_to_mirrorObject



7
8
9
10
# File 'lib/ethon/easy/mirror.rb', line 7

def self.informations_to_mirror
  Informations::AVAILABLE_INFORMATIONS.keys +
    [:return_code, :response_headers, :response_body, :debug_info]
end

Instance Method Details

#log_informationsObject



28
29
30
31
32
# File 'lib/ethon/easy/mirror.rb', line 28

def log_informations
  Hash[*self.class.informations_to_log.map do |info|
    [info, options[info]]
  end.flatten]
end