lib/karafka/web/ui/controllers/base_controller.rb in karafka-web-0.9.1 vs lib/karafka/web/ui/controllers/base_controller.rb in karafka-web-0.10.0.beta1

- old
+ new

@@ -31,11 +31,11 @@ # @return [Responses::Render] data that should be used to render appropriate view def render attributes = {} scope = self.class.to_s.split('::').last.gsub(/(.)([A-Z])/, '\1_\2').downcase.gsub('_controller', '') - action = caller_locations(1, 1)[0].label + action = caller_locations(1, 1)[0].label.split('#').last instance_variables.each do |iv| next if iv.to_s.start_with?('@_') next if iv.to_s.start_with?('@params') @@ -64,19 +64,21 @@ # @return [Responses::File] file response result def file(content, file_name) Responses::File.new(content, file_name) end - # Builds a halt 403 response - def deny - Responses::Deny.new + # Raises the deny error so we can render a deny block + # We handle this that way so we can raise this from any place we want as long as within + # the Roda flow and not only from controllers + def deny! + raise Errors::Ui::ForbiddenError end # @param resources [Hash, Array, Lib::HashProxy] object for sorting # @return [Hash, Array, Lib::HashProxy] sorted results def refine(resources) Lib::Sorter.new( - @params.sort, + @params.current_sort, allowed_attributes: self.class.sortable_attributes ).call(resources) end # Initializes the expected pagination engine and assigns expected arguments