Module: SeemsRateable::Helpers::ActionViewExtension

Defined in:
lib/seems_rateable/helpers/action_view_extension.rb

Instance Method Summary collapse

Instance Method Details

#rating_for(rateable, options = {}) ⇒ Object



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

def rating_for(rateable, options={})
  unless rateable.kind_of? Models::ActiveRecordExtension::Rateable
    raise Errors::InvalidRateableError, "#{rateable.inspect} is not a rateable" +
      " object, try adding 'seems_rateable' into your object's model"
  end

  if !current_rater || rateable.rated_by?(current_rater, options[:dimension])
    options[:disabled] = true
  end

  SeemsRateable::Builder.build(rateable, options)
end