Class: HTTParrot::Config

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

Class Method Summary collapse

Class Method Details

.configObject



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

def self.config
  @config.instance_variable_get(:@table)
end

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



11
12
13
# File 'lib/httparrot.rb', line 11

def self.configure 
  yield self
end

.method_missing(sym, *args, &blk) ⇒ Object



37
38
39
40
41
42
43
44
45
46
# File 'lib/httparrot.rb', line 37

def self.method_missing(sym, *args, &blk)
  case 
  when sym.to_s =~ /(.+)=$/ && valid_key?($1.to_sym) then
    @config.send(sym, *args, &blk)
  when @config.respond_to?(sym) then
    @config.send(sym, *args, &blk)
  else 
    super
  end
end

.restore_defaults!Object



27
28
29
30
31
32
33
34
35
# File 'lib/httparrot.rb', line 27

def self.restore_defaults!
  self.configure do |c|
    c.Port = 4000
    c.SSLPort = c.Port + 1
    c.ssl = true
    c.verbose = false
    c.template_root = nil
  end
end

.valid_key?(key) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
22
23
24
25
# File 'lib/httparrot.rb', line 19

def self.valid_key?(key)
  [ :Port, 
    :SSLPort,
    :ssl,
    :template_root,
    :verbose ].include?(key)
end