Socket
Book a DemoInstallSign in
Socket

activist

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

activist

0.0.8
bundlerRubygems
Version published
Maintainers
1
Created
Source

Activist

Activity stream in rails 3.0 applications

Based on http://activitystrea.ms/spec/1.0/atom-activity-01.html

Requirements

  • Redis

Installation

Just run the following command :

gem install activist

Then in your Gemfile add the following line :

gem 'activist'

And run

bundle install

Usage

First generate a status model :

rails generate activist:install

This command creates a new model called ActivistStatus in 'app/models' :

class ActivistStatus < ActiveRecord::Base
  serialize :data, Hash
end

It also creates a new migration for the ActivistStatus model so don't forget to migrate your database :

rake db:migrate

Then add activist in your user model :

class User < ActiveRecord::Base
  include Activist::Actor
  
  stream :public do
    all
  end
  
  stream :private do
    [user]
  end
end

And finally create some activities :

class Post < ActiveRecord::Base
  include Activist::Action
  
  belongs_to :user
  
  activities :public, :on => :after_create
  activities :private, :actor => :user, :action => :posted, :on => :after_create
  activities :public, :on => :after_update, :data => proc { |post| post.changes }
  
  after_destroy
    activity :private, :action => :deleted
  end
  
  def promote
    self.title = "[PROMOTED] #{self.title}"
    activity :private, :action => :promoted, :data => proc { |post| { :title => post.title } }
  end
end

FAQs

Package last updated on 28 Jul 2011

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.