Module: Shrine::Plugins::DownloadEndpoint::ClassMethods

Defined in:
lib/shrine/plugins/download_endpoint.rb

Instance Method Summary collapse

Instance Method Details

#assign_download_endpoint(app_class) ⇒ Object

Assigns the subclassed endpoint as the ‘DownloadEndpoint` constant.



36
37
38
39
40
41
# File 'lib/shrine/plugins/download_endpoint.rb', line 36

def assign_download_endpoint(app_class)
  @download_endpoint = new_download_endpoint(app_class)

  const_set(:DownloadEndpoint, @download_endpoint)
  deprecate_constant(:DownloadEndpoint)
end

#download_endpoint(**options) ⇒ Object

Returns the Rack application that retrieves requested files.



31
32
33
# File 'lib/shrine/plugins/download_endpoint.rb', line 31

def download_endpoint(**options)
  new_download_endpoint(App, **options)
end

#inherited(subclass) ⇒ Object

Assigns the subclass a copy of the download endpoint class.



25
26
27
28
# File 'lib/shrine/plugins/download_endpoint.rb', line 25

def inherited(subclass)
  super
  subclass.assign_download_endpoint(@download_endpoint)
end