module Metricky::Helper
Public Instance Methods
metric_form_for(metric) { |f| ... }
click to toggle source
# File lib/metricky/helper.rb, line 3 def metric_form_for(metric) form_for("#{request.path}", as: metric.form_name.to_sym, method: :get) do |f| yield(f) end end
metrick_path(metric, options = {})
click to toggle source
# File lib/metricky/helper.rb, line 9 def metrick_path(metric, options = {}) metricky.metric_path(name: metric.name.underscore, query: request.query_parameters, options: options) end
metricky_chart(metric, options = {})
click to toggle source
# File lib/metricky/helper.rb, line 30 def metricky_chart(metric, options = {}) if metric.json? send(metric.chart, metrick_path(metric, options)) else send(metric.chart, metric.results, options) end end
render_metric(metric_name, options = {})
click to toggle source
# File lib/metricky/helper.rb, line 13 def render_metric(metric_name, options = {}) if metric_name.is_a?(String) || metric_name.is_a?(Symbol) metric_name = metric_name.to_s if metric_name.end_with?("Metric") metric = metric_name.safe_constantize else klass_name = "#{metric_name.to_s}Metric".camelize metric = "#{klass_name}".safe_constantize end raise NameError, "#{metric_name} does not exist" unless metric else metric = metric_name end metric = metric.new(params, options) render metric, metric: metric end