Class: Dina::File
- Inherits:
-
Object
- Object
- Dina::File
- Defined in:
- lib/dina/models/object_store/file.rb
Instance Attribute Summary collapse
-
#file_path ⇒ Object
Returns the value of attribute file_path.
-
#group ⇒ Object
Returns the value of attribute group.
-
#id ⇒ Object
Returns the value of attribute id.
-
#is_derivative ⇒ Object
Returns the value of attribute is_derivative.
Class Method Summary collapse
Instance Method Summary collapse
- #endpoint ⇒ Object
- #endpoint_path ⇒ Object
- #file ⇒ Object
-
#initialize ⇒ File
constructor
A new instance of File.
- #save ⇒ Object
- #table_name ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize ⇒ File
Returns a new instance of File.
15 16 |
# File 'lib/dina/models/object_store/file.rb', line 15 def initialize end |
Instance Attribute Details
#file_path ⇒ Object
Returns the value of attribute file_path.
3 4 5 |
# File 'lib/dina/models/object_store/file.rb', line 3 def file_path @file_path end |
#group ⇒ Object
Returns the value of attribute group.
3 4 5 |
# File 'lib/dina/models/object_store/file.rb', line 3 def group @group end |
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'lib/dina/models/object_store/file.rb', line 3 def id @id end |
#is_derivative ⇒ Object
Returns the value of attribute is_derivative.
3 4 5 |
# File 'lib/dina/models/object_store/file.rb', line 3 def is_derivative @is_derivative end |
Class Method Details
.find(group:, id:) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/dina/models/object_store/file.rb', line 5 def self.find(group:, id:) obj = self.new obj.group = group RestClient::Request.execute( method: :get, headers: { authorization: Dina::Authentication.header }, url: obj.url + "/#{id}" ) end |
Instance Method Details
#endpoint ⇒ Object
18 19 20 |
# File 'lib/dina/models/object_store/file.rb', line 18 def endpoint Dina::Authentication.endpoint_url end |
#endpoint_path ⇒ Object
22 23 24 |
# File 'lib/dina/models/object_store/file.rb', line 22 def endpoint_path "objectstore-api/" end |
#file ⇒ Object
34 35 36 |
# File 'lib/dina/models/object_store/file.rb', line 34 def file ::File.new(file_path) end |
#save ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/dina/models/object_store/file.rb', line 38 def save validate_params response = RestClient::Request.execute( method: :post, headers: { authorization: Dina::Authentication.header }, url: (!is_derivative) ? url : url + "/derivative", payload: { multipart: true, file: file } ) json = JSON.parse(response, symbolize_names: true) self.id = json[:uuid] json end |
#table_name ⇒ Object
26 27 28 |
# File 'lib/dina/models/object_store/file.rb', line 26 def table_name "file/#{@group.downcase}" end |
#url ⇒ Object
30 31 32 |
# File 'lib/dina/models/object_store/file.rb', line 30 def url endpoint + "/" + endpoint_path + table_name end |