Project

opt_out

0.0
No commit activity in last 3 years
No release in over 3 years
Track newsletter unsubscriptions
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

 Project Readme

OptOut

OptOut is a rubygem for tracking unsubscriptions to newsletters.

Usage

OptOut.unsubscribe('newsletters', '5')  # unsubscribe user id '5' from 'newsletters'
OptOut.subscribed?('newsletters', '5')
=> false

OptOut.subscribe('newsletters', '5')  # re-subscribe a user to 'newsletters'
OptOut.subscribed?('newsletters', '5')
=> true

OptOut.unsubscribed?('newsletters', '5')  # another way to query
=> false

OptOut.subscribed('newsletters', '8')  # users are subscribed by default unless explicitly unsubscribed
=> true

['1', '2', '3'].each {|user_id| OptOut.unsubscribe('newsletters', user_id)}
OptOut.unsubscribers  # returns a list of unsubscribed user ids
=> ['1', '2', '3']

Configuration

The persistence backend can be configured to be one of:

For example, to configure OptOut to store unsubscriptions in Redis:

OptOut.configure do |c|
  c.adapter = OptOut::Adapters::RedisAdapter
  c.options = {
    :url => 'redis://localhost:6379'
  }
end

See individual adapter classes for setup and configuration options. To write a custom adapter, take a look at AbstractAdapter

Development

To run tests, you will need a running redis instance. Add a .env file to the project root to configure where redis lives:

REDIS_URL=redis://localhost:6379

To run tests:

$ rake

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request