Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

popstar3

Package Overview
Dependencies
Maintainers
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

popstar3

  • 1.0.3
  • Rubygems
  • Socket score

Version published
Maintainers
3
Created
Source

Popstar3

Mongoid >= 3.0.0 support of Popstar repo


Popularity system for your Rails models.

Installation

Put this in your gemfile:

gem 'popstar3'

Usage

Define your badge rules in a PopularityRules class

class PopularityRules
  include Popstar3::Popularity

  def initialize
    popularity_for :voteable do
      on :create, Vote, :rate => proc { |vote| vote.rate*2 }
      on :update, Vote, :rate => proc { |vote| (vote.rate - vote.rate_was)*2 }
    end

    popularity_for :question do
      on :create, Answer, :rate => 2
    end

    popularity_for :viewable do
      on :create, ViewsCount
    end

    popularity_for :widget do
      on :create, Comment
      on :create, Question, :rate => 2
      on :create, Answer, :rate => 3
    end
  end
end

Supported ORMS

  • Mongoid >= 3.0.0

TODO

  • Add support for ActiveRecord
  • Add rake tasks to migrate popular models after defining rules

FAQs

Package last updated on 16 Nov 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc