Class: DatabasusRuby::Record
- Defined in:
- lib/databasus_ruby/record.rb,
sig/databasus_ruby.rbs
Overview
A payload that remembers the client it came from, so the record can reach the endpoints related to it:
client.databases.get(id).backups(status: "COMPLETED")
Plain Object stays the wrapper for nested fields and for responses that have nothing hanging off them; Record exists only for the payloads whose domain has related endpoints.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#client ⇒ Client
readonly
Returns the value of attribute client.
Instance Method Summary collapse
-
#id! ⇒ String
Related endpoints address the record by id, and the API omits empty fields, so a record built from a partial payload has to say so rather than sending a request with a nil id.
-
#initialize(client, attributes = {}) ⇒ Record
constructor
A new instance of Record.
Methods inherited from Object
#==, #[], #hash, #inspect, #key?, #keys, #method_missing, #respond_to_missing?, #to_h
Constructor Details
#initialize(client, attributes = {}) ⇒ Record
Returns a new instance of Record.
15 16 17 18 |
# File 'lib/databasus_ruby/record.rb', line 15 def initialize(client, attributes = {}) @client = client super(attributes) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class DatabasusRuby::Object
Instance Attribute Details
#client ⇒ Client (readonly)
Returns the value of attribute client.
13 14 15 |
# File 'lib/databasus_ruby/record.rb', line 13 def client @client end |
Instance Method Details
#id! ⇒ String
Related endpoints address the record by id, and the API omits empty fields, so a record built from a partial payload has to say so rather than sending a request with a nil id.
25 26 27 28 29 30 |
# File 'lib/databasus_ruby/record.rb', line 25 def id! value = self["id"] raise Error, "this #{self.class.name} has no id" if value.nil? || value.to_s.empty? value end |