Class: VoiceTel::Resources::Base
- Inherits:
-
Object
- Object
- VoiceTel::Resources::Base
- Defined in:
- lib/voicetel/resources/base.rb
Overview
Shared base for every resource service. Each service receives the client’s transport on construction and uses it for HTTP calls. Keeping this thin lets us keep resource files focused on their endpoints.
Direct Known Subclasses
Account, Acl, Authentication, E911, Gateways, INumbering, Lookups, Messaging, Numbers, Support
Instance Method Summary collapse
-
#compact_query(hash) ⇒ Object
Compact a query hash, dropping nil and empty-string values, before handing it to the transport.
-
#initialize(transport) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(transport) ⇒ Base
Returns a new instance of Base.
9 10 11 |
# File 'lib/voicetel/resources/base.rb', line 9 def initialize(transport) @transport = transport end |
Instance Method Details
#compact_query(hash) ⇒ Object
Compact a query hash, dropping nil and empty-string values, before handing it to the transport. Some endpoints take a lot of optional filters and writing ‘nil` everywhere at call sites would be noisy.
16 17 18 |
# File 'lib/voicetel/resources/base.rb', line 16 def compact_query(hash) hash.reject { |_, v| v.nil? || v == "" } end |