Class: SmartEnv::UriProxy
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Class Method Summary collapse
-
.when(key, value) ⇒ Object
for SmartEnv.
Instance Method Summary collapse
- #base_uri(port = true) ⇒ Object
-
#initialize(_key, uri) ⇒ UriProxy
constructor
A new instance of UriProxy.
- #method_missing(method, *args, &block) ⇒ Object
Constructor Details
#initialize(_key, uri) ⇒ UriProxy
Returns a new instance of UriProxy.
15 16 17 18 19 20 21 22 |
# File 'lib/smart_env/uri_proxy.rb', line 15 def initialize(_key, uri) @original = uri @uri = ::URI.parse(uri) @params = ::CGI.parse(@uri.query.to_s) @params.each do |key, values| @params[key] = values.first if values.size == 1 end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
34 35 36 |
# File 'lib/smart_env/uri_proxy.rb', line 34 def method_missing(method, *args, &block) @original.send(method, *args, &block) end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
11 12 13 |
# File 'lib/smart_env/uri_proxy.rb', line 11 def params @params end |
Class Method Details
.when(key, value) ⇒ Object
for SmartEnv
25 26 27 |
# File 'lib/smart_env/uri_proxy.rb', line 25 def self.when(key, value) value.match(/^\w+:\/\//) end |
Instance Method Details
#base_uri(port = true) ⇒ Object
29 30 31 32 |
# File 'lib/smart_env/uri_proxy.rb', line 29 def base_uri(port = true) base = "#{@uri.scheme}://#{@uri.host}" port ? "#{base}:#{@uri.port}" : base end |