Class: Dato::Upload::File
- Inherits:
-
Object
- Object
- Dato::Upload::File
- Defined in:
- lib/dato/upload/file.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#field_attributes ⇒ Object
readonly
Returns the value of attribute field_attributes.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#upload_attributes ⇒ Object
readonly
Returns the value of attribute upload_attributes.
Instance Method Summary collapse
-
#initialize(client, source, upload_attributes = {}, field_attributes = {}) ⇒ File
constructor
A new instance of File.
- #upload ⇒ Object
Constructor Details
#initialize(client, source, upload_attributes = {}, field_attributes = {}) ⇒ File
Returns a new instance of File.
10 11 12 13 14 15 |
# File 'lib/dato/upload/file.rb', line 10 def initialize(client, source, upload_attributes = {}, field_attributes = {}) @client = client @source = source @upload_attributes = upload_attributes @field_attributes = field_attributes end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
8 9 10 |
# File 'lib/dato/upload/file.rb', line 8 def client @client end |
#field_attributes ⇒ Object (readonly)
Returns the value of attribute field_attributes.
8 9 10 |
# File 'lib/dato/upload/file.rb', line 8 def field_attributes @field_attributes end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
8 9 10 |
# File 'lib/dato/upload/file.rb', line 8 def source @source end |
#upload_attributes ⇒ Object (readonly)
Returns the value of attribute upload_attributes.
8 9 10 |
# File 'lib/dato/upload/file.rb', line 8 def upload_attributes @upload_attributes end |
Instance Method Details
#upload ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/dato/upload/file.rb', line 17 def upload upload_path = CreateUploadPath.new(client, source).upload_path upload = client.uploads.create( upload_attributes.merge(path: upload_path), ) { alt: nil, title: nil, custom_data: {}, }.merge(field_attributes).merge(upload_id: upload["id"]) end |