Class: Transloadit::ApiModel
- Inherits:
-
Object
- Object
- Transloadit::ApiModel
- Defined in:
- lib/transloadit/api_model.rb
Overview
Represents an API class that more Transloadit specific API classes would inherit from.
Instance Attribute Summary collapse
-
#options ⇒ Hash
The options describing the Assembly.
-
#transloadit ⇒ Transloadit
readonly
The associated Transloadit instance.
Instance Method Summary collapse
-
#initialize(transloadit, options = {}) ⇒ ApiModel
constructor
Creates a new API instance authenticated using the given
transloadit
instance. -
#inspect ⇒ String
A human-readable version of the API.
-
#to_hash ⇒ Hash
A Transloadit-compatible Hash of the API’s contents.
-
#to_json ⇒ String
JSON-encoded String containing the API’s contents.
Constructor Details
#initialize(transloadit, options = {}) ⇒ ApiModel
Creates a new API instance authenticated using the given transloadit
instance.
21 22 23 24 |
# File 'lib/transloadit/api_model.rb', line 21 def initialize(transloadit, = {}) self.transloadit = transloadit self. = end |
Instance Attribute Details
#options ⇒ Hash
Returns the options describing the Assembly.
12 13 14 |
# File 'lib/transloadit/api_model.rb', line 12 def @options end |
#transloadit ⇒ Transloadit
Returns the associated Transloadit instance.
9 10 11 |
# File 'lib/transloadit/api_model.rb', line 9 def transloadit @transloadit end |
Instance Method Details
#inspect ⇒ String
Returns a human-readable version of the API.
29 30 31 |
# File 'lib/transloadit/api_model.rb', line 29 def inspect to_hash.inspect end |
#to_hash ⇒ Hash
Returns a Transloadit-compatible Hash of the API’s contents.
36 37 38 39 40 |
# File 'lib/transloadit/api_model.rb', line 36 def to_hash .merge( auth: transloadit.to_hash ).delete_if { |_, v| v.nil? } end |
#to_json ⇒ String
Returns JSON-encoded String containing the API’s contents.
45 46 47 |
# File 'lib/transloadit/api_model.rb', line 45 def to_json MultiJson.dump(to_hash) end |