Class: Cargowise::AbstractResult
- Inherits:
-
Object
- Object
- Cargowise::AbstractResult
show all
- Defined in:
- lib/cargowise/abstract_result.rb
Overview
Superclass of all objects built to contain results from the API. Not much to see here, mostly common helper methods for parsing values out of the XML response.
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.endpoint(name) ⇒ Object
16
17
18
19
|
# File 'lib/cargowise/abstract_result.rb', line 16
def self.endpoint(name)
@endpoints ||= {}
@endpoints[name]
end
|
.register(name, opts = {}) ⇒ Object
11
12
13
14
|
# File 'lib/cargowise/abstract_result.rb', line 11
def self.register(name, opts = {})
@endpoints ||= {}
@endpoints[name] = Endpoint.new(opts)
end
|
.via(name) ⇒ Object
21
22
23
24
25
26
27
28
|
# File 'lib/cargowise/abstract_result.rb', line 21
def self.via(name)
@endpoints ||= {}
raise ArgumentError, "#{name} is not recognised, have you registered it?" if @endpoints[name].nil?
klass_name = (self.name[/Cargowise::(.+)/,1] + "Search")
search_klass = Cargowise.const_get(klass_name)
search_klass.new(@endpoints[name])
end
|
Instance Method Details
#inspect ⇒ Object
30
31
32
33
34
35
|
# File 'lib/cargowise/abstract_result.rb', line 30
def inspect
str = "<#{self.class}: "
str << inspectable_vars.map { |v| "#{v.to_s.tr('@','')}: #{instance_variable_get(v)}" }.join(" ")
str << ">"
str
end
|