Sha256: 8a36c29ba634220856e96fd3600c5613968b5b503e4fc6a6e6b21ec6fcee0c33

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

# Emotions

Emotions is a Ruby library that allows ActiveRecord records to express (and hopefully store) emotions about other records.

## Installation

Add this line to your application’s Gemfile:

```ruby
gem 'emotions'
```

And then execute:

```bash
$ bundle
```

Run the migration to add the `emotions` table:

```bash
$ rails generate emotions:install
```

## Usage

Configure the allowed emotions.

```ruby
Emotions.configure do |config|
  config.emotions = [:happy, :sad]
end
```

Create a couple of models.

```ruby
class Picture < ActiveRecord::Base
  acts_as_emotive
end

class User < ActiveRecord::Base
  acts_as_emotional
end
```

Express emotions towards other records.

```ruby
user = User.find(1)
picture = Picture.find(2)

user.happy_about!(picture)
user.sad_about!(picture)
user.emotions_about(picture)
# => [:happy, :sad]

user.happy_about?(picture)
# => true

user.no_longer_sad_about!(picture)
user.sad_about?(picture)
# => false

picture.happy_about.map(&:emotional)
# => [#<User id=1>]

user.express!(:sad, picture)
user.sad_about?(picure)
# => true
```

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
emotions-0.1.1 README.md
emotions-0.1 README.md