herder
The herder that allows all animals to talk to the hamster
Installation
Add to Gemfile for a Rails app:
gem "herder"
Bundle and then add a config/herder.yml
site: http://localhost:3000/
user: "username"
password: "password"
Or don't add the yml file to fall back on the ENV variables HERDER_SITE
, HERDER_USER
and HERDER_PASSWORD
. This is useful for Heroku.
Basic usage
For now Herder adds a few built in ActiveResource classes.
Herder::Attendee
- has many
Herder::Emails
- has many
Herder::Tickets
Herder::Email
- belongs to
Herder::Attendee
Herder::Ticket
- belongs to
Herder::Attendee
- belongs to
Herder::Event
Herder::Event
- has many
Herder::Tickets
- belongs to
Herder::Venue
Herder::Venue
For full usage details read the ActiveResource documentation.
Herder::Attendee.find(1)
Alternatively you can make your own models to extend the base classes:
class Attendee < Herder::Attendee
end
Attendee.find(1)
Using interactions
Interactions are a handy key-value attributes that can be set on other classes (Interactables). This is handy as it means we don't need to add loads of extra booleans to Hamster for every little thing we might need to keep track of.
Note: Interactions are never deleted, hence you can always get a full log of interactions including date and time of when something changed value.
Acting on a record
ticket = Ticket.find(1)
ticket.interactions.checkin = true
ticket.interactions.checkin.toggle
ticket.interactions.checkin.undo!
ticket.interactions.checkin
ticket.interactions.checkin?
ticket.interactions.limit(5).checkin
ticket.interactions.limit(5).oldest.checkin
ticket.interactions
Acting on a table
Note: These methods return the objects they are performed on (in this case Ticket).
event = Event.find(1)
event.tickets.where("interactions.confirmed = true")
event.tickets.where("interactions.confirmed != true")
event.tickets.where("interactions.cancelled = true")
event.tickets.where("interactions.checkin ~ true")
event.tickets.where("interactions.checkin !~ true")
event.tickets.where("interactions.checkin = true")
event.tickets.where("interactions.checkin != true")
event.tickets.where("interactions.checkin ~ ? AND interactions.created_at < ? AND interactions.created_at > ?", true, Time.now, 3.days.ago)
event.tickets.where("interactions.checkin !~ ? AND interactions.created_at < ? AND interactions.created_at > ?", false, Time.now, 3.days.ago)
event.tickets.where("interactions.permanently_left = true")
event.tickets.where("interactions.permanently_left != true")
Changelog
- 0.0.5 - Dependency fix
- 0.0.4 - Added events and venues
- 0.0.3 - Added interactions and interactables
- 0.0.2 - Added emails, tickets, and association
- 0.0.1 - Added basic attendee interface
License
See LICENSE