Class: HTTParrot::Config
- Inherits:
-
Object
- Object
- HTTParrot::Config
- Defined in:
- lib/httparrot.rb
Class Method Summary collapse
- .config ⇒ Object
- .configure {|_self| ... } ⇒ Object
- .method_missing(sym, *args, &blk) ⇒ Object
- .restore_defaults! ⇒ Object
- .valid_key?(key) ⇒ Boolean
Class Method Details
.config ⇒ Object
15 16 17 |
# File 'lib/httparrot.rb', line 15 def self.config @config.instance_variable_get(:@table) end |
.configure {|_self| ... } ⇒ Object
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
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 |