Class: Metricky::MetricsController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/metricky/metrics_controller.rb

Instance Method Summary collapse

Instance Method Details

#showObject



3
4
5
6
7
8
9
# File 'app/controllers/metricky/metrics_controller.rb', line 3

def show
  metric = "#{params[:name].classify}Metric".constantize.new(params[:query] || {}, params[:options] || {})
  unless metric.results.is_a?(Hash) || metric.results.is_a?(Array)
    raise RenderError, "results must be a hash or array"
  end
  render json: metric.to_json
end