Sha256: 7e2e3541be174cd5030d240d6ad64e6a92e4740f8a3e5af4e9a3d5dfa04601f3

Contents?: true

Size: 435 Bytes

Versions: 2

Compression:

Stored size: 435 Bytes

Contents

module MakeVoteable
  module Voteable
    extend ActiveSupport::Concern

    included do
      has_many :votings, :class_name => "MakeVoteable::Voting", :as => :voteable
    end

    module ClassMethods
      def voteable?
        true
      end
    end

    # Return the difference of down and up votes.
    # May be negative if there are more down than up votes.
    def votes
      self.up_votes - self.down_votes
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
make_voteable-0.1.1 lib/make_voteable/voteable.rb
make_voteable-0.1.0 lib/make_voteable/voteable.rb