Class: Ogc::AbstractBase
- Inherits:
-
Object
- Object
- Ogc::AbstractBase
- Includes:
- Errors
- Defined in:
- lib/ogc/abstract_base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #get(extra_params, &block) ⇒ Object
- #http ⇒ Object
-
#initialize(url, params = nil) ⇒ AbstractBase
constructor
A new instance of AbstractBase.
- #post(body, &block) ⇒ Object
Constructor Details
#initialize(url, params = nil) ⇒ AbstractBase
Returns a new instance of AbstractBase.
24 25 26 27 28 |
# File 'lib/ogc/abstract_base.rb', line 24 def initialize(url, params = nil) @url = url @params = params.is_a?(Hash) ? params.stringify_keys : {} @params.merge!(default_params) if default_params.is_a?(Hash) end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
14 15 16 |
# File 'lib/ogc/abstract_base.rb', line 14 def params @params end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
14 15 16 |
# File 'lib/ogc/abstract_base.rb', line 14 def response @response end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
14 15 16 |
# File 'lib/ogc/abstract_base.rb', line 14 def url @url end |
Class Method Details
.request_name ⇒ Object
19 20 21 |
# File 'lib/ogc/abstract_base.rb', line 19 def request_name @request_name ||= to_s.demodulize end |
Instance Method Details
#get(extra_params, &block) ⇒ Object
30 31 32 33 |
# File 'lib/ogc/abstract_base.rb', line 30 def get(extra_params, &block) params = extra_params ? extra_params.merge(@params) : @params fetch(:get, params, &block) end |
#http ⇒ Object
39 40 41 |
# File 'lib/ogc/abstract_base.rb', line 39 def http @http ||= Net::HTTP.new(uri.host, uri.port) end |
#post(body, &block) ⇒ Object
35 36 37 |
# File 'lib/ogc/abstract_base.rb', line 35 def post(body, &block) fetch(:post, body.respond_to?(:to_xml) ? body.to_xml : body, &block) end |