lib/massive/file.rb in massive-0.2.0 vs lib/massive/file.rb in massive-0.3.0
- old
+ new
@@ -38,11 +38,11 @@
def has_info?
[:encoding, :col_sep, :total_count].all? { |field| send(field).present? }
end
def url
- read_attribute(:url).presence || authenticated_url
+ read_attribute(:url).presence || authenticator.url
end
private
def clear_info
@@ -57,28 +57,10 @@
encoding: encoding,
col_sep: col_sep
}
end
- def authenticated_url
- if can_use_fog?
- fog_file.respond_to?(:url) ? fog_file.url(Time.current.to_i + Massive.fog_authenticated_url_expiration) : fog_file.public_url
- end
- end
-
- def can_use_fog?
- filename && Massive.fog_credentials.present?
- end
-
- def fog_connection
- @fog_connection ||= Fog::Storage.new(Massive.fog_credentials)
- end
-
- def fog_directory
- @fog_directory ||= fog_connection.directories.get(Massive.fog_directory)
- end
-
- def fog_file
- @fog_file ||= fog_directory.files.get(filename)
+ def authenticator
+ @authenticator ||= Massive.storage_config[:provider].new(filename)
end
end
end