Sha256: 8cba87bb90411391648061c24946371ac9119c0de4f96e768e38c1b341574ff3

Contents?: true

Size: 721 Bytes

Versions: 10

Compression:

Stored size: 721 Bytes

Contents

module Neutral
  module Model
    module ActiveRecordExtension
      def neutral
        include Voteable
      end

      def neutral_voter
        include Voter
      end

      module Voteable
        extend ActiveSupport::Concern

        included do
          has_many :votes, as: :voteable, class_name: Neutral::Vote, dependent: :destroy
          has_one :voting, as: :votingable, class_name: Neutral::Voting, dependent: :destroy
          has_many :voters, through: :votes, source: :voter
        end
      end

      module Voter
        extend ActiveSupport::Concern

        included do
          has_many :votes_given, class_name: Neutral::Vote, foreign_key: :voter_id
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
neutral-0.0.10 lib/neutral/model/active_record_extension.rb
neutral-0.0.9 lib/neutral/model/active_record_extension.rb
neutral-0.0.8 lib/neutral/model/active_record_extension.rb
neutral-0.0.7 lib/neutral/model/active_record_extension.rb
neutral-0.0.6 lib/neutral/model/active_record_extension.rb
neutral-0.0.5 lib/neutral/model/active_record_extension.rb
neutral-0.0.4 lib/neutral/model/active_record_extension.rb
neutral-0.0.3 lib/neutral/model/active_record_extension.rb
neutral-0.0.2 lib/neutral/model/active_record_extension.rb
neutral-0.0.1 lib/neutral/model/active_record_extension.rb