Class: Boar::Services::Downloads
- Defined in:
- app/models/boar/services/downloads.rb
Instance Attribute Summary collapse
-
#downloads_configuration ⇒ Object
Returns the value of attribute downloads_configuration.
Attributes inherited from Generic
#configuration, #controller, #options, #params
Instance Method Summary collapse
Methods inherited from Generic
#handle_authentication, #handle_error, #handler_for, #initialize, #run
Methods included from Utils::Basic
#ensure_hash, #get_option, #interpolate
Constructor Details
This class inherits a constructor from Boar::Services::Generic
Instance Attribute Details
#downloads_configuration ⇒ Object
Returns the value of attribute downloads_configuration.
10 11 12 |
# File 'app/models/boar/services/downloads.rb', line 10 def downloads_configuration @downloads_configuration end |
Instance Method Details
#download_file(*args) ⇒ Object
54 55 56 |
# File 'app/models/boar/services/downloads.rb', line 54 def download_file(*args) @controller.send_file(*args) end |
#downloads ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/models/boar/services/downloads.rb', line 12 def downloads # Get the full path path = @params[:path] # Handle ACL for the path self.handle_authentication(path, @options) if !controller.performed? then load_configuration(@skip_cache) # Instantiate the configuration # Try to match the path against the list of files match_data = nil found = @downloads_configuration[:files].find{ |k, _| match_data = Regexp.new("^#{k}$").match(path) } raise Boar::Exceptions::NotFound.new(path) if !found # Get entry regexp, entry = split_entry(found) # Map the path path = self.handler_for(:downloads_mapper, ).call(self, path) # Now execute the provider. This will take care of acting on the controller begin provider_for_entry(entry).call(path, entry, @skip_cache, regexp, match_data) rescue ::Mbrao::Exceptions::Unimplemented => e raise Mbrao::Exceptions::Unimplemented.new(e) end end end |
#update ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/models/boar/services/downloads.rb', line 42 def update args = {nothing: true, status: :ok} begin load_configuration(true) rescue => e args = {text: e., status: 500} end @controller.render(args) end |