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

redis_timeline

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redis_timeline

  • 0.2.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

redis-timeline

Build Status

Redis backed timelines in your app.

Pair program with me!

Features

  • store your timeline in Redis.

Examples

The simple way...

class Post < ActiveRecord::Base
  include Timeline::Track

  track :new_post
end

By default, track fires in the after_create callback of your model and uses self as the object and creator as the actor.

You can specify these options explicity...

class Comment < ActiveRecord::Base
  include Timeline::Track
  belongs_to :author, class_name: "User"
  belongs_to :post

  track :new_comment,
    actor: :author,
    followers: :post_participants,
    object: [:body],
    on: :update,
    target: :post

  delegate :participants, to: :post, prefix: true
end

Parameters

track accepts the following parameters...

the first param is the verb name.

The rest all fit neatly in an options hash.

  • on: [ActiveModel callback] You use it to specify whether you want the timeline activity created after a create, update or destroy. Default: :create

  • actor: [the method that specifies the object that took this action] In the above example, comment.author is this object. Default: :creator, so make sure this exists if you don't specify a method here

  • object: defaults to self, which is good most of the time. You can override it if you need to

  • target: [related to the :object method above. In the example this is the post related to the comment] default: nil

  • followers: [who should see this story in their timeline. This references a method on the actor] Defaults to the method followers defined by Timeline::Actor.

  • extra_fields: [accepts an array of method names that you would like to cache the value of in your timeline] Defaults to nil.

  • if: symbol or proc/lambda lets you put conditions on when to track.

Display a timeline

To retrieve a timeline for a user...

class User < ActiveRecord::Base
  include Timeline::Actor
end

The timeline objects are just hashes that are extended by Hashie to provide method access to the keys.

user = User.find(1)
user.timeline # => [<Timeline::Activity verb='new_comment' ...>]

Requirements

  • redis
  • active_support
  • hashie

Install

Install redis.

Add to your Gemfile:

gem 'redis-timeline'

Or install it by hand:

gem install redis-timeline

Setup your redis instance. For a Rails app, something like this...

# in config/initializers/redis.rb

Timeline.redis = "localhost:6379/timeline"

Author

Original author: Felix Clack

License

(The MIT License)

Copyright (c) 2012 Felix Clack

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

FAQs

Package last updated on 11 Apr 2014

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