Sha256: f6928b9f01510d276a882923a51bee3bcb87490fc91e1affb67a3e7c14329847
Contents?: true
Size: 841 Bytes
Versions: 15
Compression:
Stored size: 841 Bytes
Contents
module ForestLiana class StatsController < ForestLiana::ApplicationController before_filter :find_resource def show case params[:type].try(:downcase) when 'value' stat = ValueStatGetter.new(@resource, params) when 'pie' stat = PieStatGetter.new(@resource, params) when 'line' stat = LineStatGetter.new(@resource, params) end stat.perform if stat.record render json: serialize_model(stat.record) else render json: {status: 404}, status: :not_found end end private def find_resource @resource = SchemaUtils.find_model_from_table_name(params[:collection]) if @resource.nil? || !@resource.ancestors.include?(ActiveRecord::Base) render json: {status: 404}, status: :not_found end end end end
Version data entries
15 entries across 15 versions & 1 rubygems