Sha256: 05105cb71247d2d90df6d6f6c1fc61cbaa6197f3fc04e832e1264d561a181891

Contents?: true

Size: 710 Bytes

Versions: 4

Compression:

Stored size: 710 Bytes

Contents

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

        included do
          key :votes, Hash, :default => DEFAULT_VOTES
          
          class << self
            alias_method :voteable_index, :ensure_index
            alias_method :voteable_collection, :collection
          end
        end

        module ClassMethods
          def voteable_relation(class_name)
            associations.find{ |x, r| r.class_name == class_name }.try(:last)
          end
          
          def voteable_foreign_key(metadata)
            (metadata.options[:in] || "#{metadata.name}_id").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/mongo_mapper.rb
voteable_mongo-0.9.2 lib/voteable_mongo/integrations/mongo_mapper.rb
voteable_mongo-0.9.1 lib/voteable_mongo/integrations/mongo_mapper.rb
voteable_mongo-0.9.0 lib/voteable_mongo/integrations/mongo_mapper.rb