Class: ReverseProxy::Bind::Formatter

Inherits:
Object
  • Object
show all
Defined in:
lib/reverse_proxy/bind.rb

Direct Known Subclasses

Tcp, Unix

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Formatter

Returns a new instance of Formatter.



13
14
15
# File 'lib/reverse_proxy/bind.rb', line 13

def initialize data
  @data = data
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method) ⇒ Object (private)



20
21
22
23
# File 'lib/reverse_proxy/bind.rb', line 20

def method_missing method
  return @bind.send method if @bind.respond_to? method
  format("#{method}".scan(/^to_([a-z]+)/)[0][0])
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



12
13
14
# File 'lib/reverse_proxy/bind.rb', line 12

def data
  @data
end

Class Method Details

.add(type, format) ⇒ Object



5
6
7
# File 'lib/reverse_proxy/bind.rb', line 5

def add type, format
  formats[type.to_s] = format
end

.formatsObject



8
9
10
# File 'lib/reverse_proxy/bind.rb', line 8

def formats
  @@formats ||= {}
end