Sha256: 8212417ec5b4611c961e4070c60c6e61c87284765c91e033094e21dc04759cbf

Contents?: true

Size: 698 Bytes

Versions: 4

Compression:

Stored size: 698 Bytes

Contents

module Mongo
  module Voteable
    module Integrations
      module Mongoid
        extend ActiveSupport::Concern

        included do
          field :votes, :type => Hash, :default => DEFAULT_VOTES

          class << self
            alias_method :voteable_index, :index
          end
        end
        
        module ClassMethods
          def voteable_relation(class_name)
            relations.find{ |x, r| r.class_name == class_name }.try(:last)
          end

          def voteable_collection
            collection.master.collection
          end

          def voteable_foreign_key(metadata)
            metadata.foreign_key.to_s
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
voteable_mongo-0.9.3 lib/voteable_mongo/integrations/mongoid.rb
voteable_mongo-0.9.2 lib/voteable_mongo/integrations/mongoid.rb
voteable_mongo-0.9.1 lib/voteable_mongo/integrations/mongoid.rb
voteable_mongo-0.9.0 lib/voteable_mongo/integrations/mongoid.rb