Sha256: 025413cd05cf0998b32e396d432d2ec7592e53c37ac81a2cd7cbb323b93b0a79

Contents?: true

Size: 817 Bytes

Versions: 2

Compression:

Stored size: 817 Bytes

Contents

module ReportsKit
  module Reports
    class GenerateAutocompleteMethodResults
      attr_accessor :filter_key, :params, :properties

      def initialize(filter_key, properties, params)
        self.filter_key = filter_key
        self.params = params
        self.properties = properties
      end

      def perform
        return unless properties[:ui_filters]
        klass, method_name = ReportsKit::Utils.string_to_class_method(autocomplete_method, 'autocomplete_method')
        klass.public_send(method_name, params, properties)
      end

      private

      def filter_hash
        properties[:ui_filters].find { |filter_params| filter_params.is_a?(Hash) && filter_params[:key] == filter_key }
      end

      def autocomplete_method
        filter_hash[:autocomplete_method]
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
reports_kit-0.7.1 lib/reports_kit/reports/generate_autocomplete_method_results.rb
reports_kit-0.7.0 lib/reports_kit/reports/generate_autocomplete_method_results.rb