Class: HAProxyCluster::StatsContainer

Inherits:
Object
  • Object
show all
Defined in:
lib/haproxy_cluster/stats_container.rb

Direct Known Subclasses

Backend, Server

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stats = {}) ⇒ StatsContainer

Returns a new instance of StatsContainer.



8
9
10
11
# File 'lib/haproxy_cluster/stats_container.rb', line 8

def initialize(stats = {})
  @stats = stats
  @monitor_fields = [:status]
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args, &block) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/haproxy_cluster/stats_container.rb', line 31

def method_missing(m, *args, &block)
  if @stats.has_key? m
    @stats[m]
  else
    super
  end
end

Instance Attribute Details

#statsObject

Returns the value of attribute stats.



13
14
15
# File 'lib/haproxy_cluster/stats_container.rb', line 13

def stats
  @stats
end

Instance Method Details

#monitor(field) ⇒ Object



15
16
17
# File 'lib/haproxy_cluster/stats_container.rb', line 15

def monitor(field)
  @monitor_fields << field.to_sym
end