Sha256: a8d07859529fcf082f3a5809c199caf1c333e41e1ea3670458c880ae3881420a
Contents?: true
Size: 1.87 KB
Versions: 2
Compression:
Stored size: 1.87 KB
Contents
# OptOut OptOut is a rubygem for tracking unsubscriptions to newsletters. ## Usage ```ruby 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: * [MemoryAdapter](lib/opt_out/adapters/memory_adapter.rb) * [RedisAdapter](lib/opt_out/adapters/redis_adapter.rb) * [ActiveRecordAdapter](lib/opt_out/adapters/active_record_adapter.rb) For example, to configure OptOut to store unsubscriptions in Redis: ```ruby 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](lib/opt_out/adapters/abstract_adapter.rb) ## 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: ```sh $ rake ``` ## Contributing 1. [Fork it](https://help.github.com/articles/fork-a-repo) 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](https://help.github.com/articles/using-pull-requests)
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
opt_out-1.1.0 | README.md |
opt_out-1.0.0 | README.md |