Sha256: f84d3913808a2cf62e83c51646563194b12243706a400ce08d3b81a1858570c2
Contents?: true
Size: 979 Bytes
Versions: 44
Compression:
Stored size: 979 Bytes
Contents
module ForestLiana class StatsController < ForestLiana::ApplicationController if Rails::VERSION::MAJOR < 4 before_filter :find_resource else before_action :find_resource end 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), serializer: nil else render json: {status: 404}, status: :not_found, serializer: nil 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, serializer: nil end end end end
Version data entries
44 entries across 44 versions & 1 rubygems