Sha256: 3f924e17912c9f95e1bb51474bfd2f0712e50d2c9f3d83944a21e6923d5728f4
Contents?: true
Size: 1.2 KB
Versions: 20
Compression:
Stored size: 1.2 KB
Contents
# frozen_string_literal: true module Karafka module Web module Ui # Namespace for controller related components in the Web UI app. module Controllers # Base controller from which all the controllers should inherit. class Base # @param params [Karafka::Web::Ui::Controllers::Requests::Params] request parameters def initialize(params) @params = params end # Builds the respond data object with assigned attributes based on instance variables. # # @return [Responses::Data] data that should be used to render appropriate view def respond attributes = {} scope = self.class.to_s.split('::').last.gsub(/(.)([A-Z])/, '\1_\2').downcase action = caller_locations(1, 1)[0].label instance_variables.each do |iv| next if iv.to_s.start_with?('@_') next if iv.to_s.start_with?('@params') attributes[iv.to_s.delete('@').to_sym] = instance_variable_get(iv) end Responses::Data.new( "#{scope}/#{action}", attributes ) end end end end end end
Version data entries
20 entries across 20 versions & 1 rubygems