Module: SeemsRateable::Helpers

Defined in:
lib/seems_rateable/helpers.rb

Instance Method Summary collapse

Instance Method Details

#rating_for(obj, opts = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/seems_rateable/helpers.rb', line 3

def rating_for(obj, opts={})
  raise Errors::InvalidRateableObjectError unless obj.class.respond_to?(:rateable?)
  
  options = {
    :dimension => nil,
    :static => false,
    :class => 'rateable',
    :id => nil
  }.update(opts)
        
   :div, "", "data-average" => obj.average(options[:dimension]) ? obj.average(options[:dimension]).avg : 0, :id => options[:id],
    :class => "#{options[:class]}#{jdisabled?(options[:static])}",
    "data-id" => obj.id, "data-kls" => obj.class.name, "data-dimension" => options[:dimension]
end

#seems_rateable_stylesheetObject



18
19
20
# File 'lib/seems_rateable/helpers.rb', line 18

def seems_rateable_stylesheet
  stylesheet_link_tag    "seems_rateable/application", media: "all", "data-turbolinks-track" => true
end