Module: RailsMetricsHelper::Scoping

Included in:
RailsMetricsHelper
Defined in:
app/helpers/rails_metrics_helper.rb

Instance Method Summary collapse

Instance Method Details

Link to clear a by_scope using a cancel image.


93
94
95
96
97
# File 'app/helpers/rails_metrics_helper.rb', line 93

def link_to_clear_by_scope(what)
  return unless instance_variable_get(:"@by_#{what}")
  link_to_set_scope_with_image("rails_metrics/cancel.png",
    "Remove #{what.to_s.humanize.inspect} filter", :"by_#{what}" => nil)
end

Link to order by scopes by using two arrows, one up and other down


100
101
102
103
# File 'app/helpers/rails_metrics_helper.rb', line 100

def link_to_order_by_scopes(up, down)
  link_to_set_scope_with_image("rails_metrics/arrow_up.png", "Order by #{up}", :order_by => up) <<
    link_to_set_scope_with_image("rails_metrics/arrow_down.png", "Order by #{down}", :order_by => down)
end

Link to set a by_scope using the given content. If no value is given, the content is used as link value as well.


86
87
88
89
90
# File 'app/helpers/rails_metrics_helper.rb', line 86

def link_to_set_by_scope(metric, what)
  value = metric.send(what)
  return value if instance_variable_get(:"@by_#{what}")
  link_to value, url_for_scope(:"by_#{what}" => value, :action => "all"), :title => value
end

#scopes_infoObject

Returns information about scope


73
74
75
76
77
78
79
80
81
82
# File 'app/helpers/rails_metrics_helper.rb', line 73

def scopes_info
  filters = []
  filters << "name" if @by_name
  filters.map!{ |i| (:b, i) }

  content = []
  content << "filtered by #{filters.to_sentence}" unless filters.empty?
  content << "ordered by <b>#{@order_by.to_s.humanize.downcase}</b>"
  content.to_sentence.html_safe
end