Sha256: f29e2fd177a5bf1c5436617534e0469d102b3c1882f508431cae171a90e3f07c
Contents?: true
Size: 993 Bytes
Versions: 39
Compression:
Stored size: 993 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_collection_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
39 entries across 39 versions & 1 rubygems