Sha256: 7ad2195761ee9a59c808d533b74ee5adb4172fc409649360056fd781c7ca04dd
Contents?: true
Size: 1.67 KB
Versions: 1
Compression:
Stored size: 1.67 KB
Contents
module Siringa class SiringaController < ApplicationController def load Siringa.load_definition(params['definition'].to_sym, options) resp = { :text => "Definition #{params['definition']} loaded.", :status => :created } rescue ArgumentError => exception resp = { :text => exception.to_s, :status => :method_not_allowed } rescue => exception resp = { :text => exception.to_s, :status => :internal_server_error } ensure render resp end def dump Siringa.keep_five_dumps(Siringa.ordered_dumps) result = Siringa.dump_to(Siringa.dump_file_name) if result[:status] resp = { :text => "DB dumped at #{result[:dump_path]}", :status => :created } else resp = { :text => "DB dump FAILED!\nError:\n#{result[:error]}", :status => :internal_server_error } end render resp end def restore last_dump = Siringa.ordered_dumps.last if last_dump result = Siringa.restore_from(last_dump) if result[:status] resp = { :text => "DB restored from #{result[:dump_path]}", :status => :accepted } else resp = { :text => "DB restore FAILED!\nError:\n#{result[:error]}", :status => :internal_server_error } end else resp = { :text => "DB restore FAILED!\nThere is no dump to restore from.", :status => :method_not_allowed } end render resp end private # Returns the arguments to be passed to the definition # # @return [Hash] arguments of the definition def options params[:siringa_args] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
siringa-0.0.6 | app/controllers/siringa/siringa_controller.rb |