Sha256: 30f487e5fb5f36a412102ce2937c5c404f6b5080fcf37ff720354fa3dcb2865d

Contents?: true

Size: 680 Bytes

Versions: 6

Compression:

Stored size: 680 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
          end

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rs_voteable_mongo-1.3.0 lib/voteable_mongo/integrations/mongoid.rb
rs_voteable_mongo-1.2.0 lib/voteable_mongo/integrations/mongoid.rb
rs_voteable_mongo-1.1.0 lib/voteable_mongo/integrations/mongoid.rb
rs_voteable_mongo-1.0.2 lib/voteable_mongo/integrations/mongoid.rb
rs_voteable_mongo-1.0.1 lib/voteable_mongo/integrations/mongoid.rb
rs_voteable_mongo-1.0.0 lib/voteable_mongo/integrations/mongoid.rb