This repository has been archived by the owner on Feb 27, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Interactables
Cristiano Betta edited this page Jun 23, 2013
·
4 revisions
#Example of how Interactables work
class Ticket
include Interactable
end
#class methods
Ticket.get_all("foo", "bar") # gets all Tickets associated to interactions with key "foo" and value "bar"
Ticket.get("foo", "bar") # gets most recent Ticket associated to interaction with key "foo" and value "bar"
Ticket.interactions("foo", "bar") # gets all interactions associated Tickets with key "foo" and value "bar"
Ticket.interaction("foo", "bar") # gets the most recent interaction associated to a Ticket with key "foo" and value "bar"
# instance methods
ticket.is_foo? # returns if current interaction with key foo is true
ticket.has_foo? # checks if interaction with key foo has ever been set
ticket.is_foo! # sets interaction with key foo to true
ticket.isnt_foo! # sets interaction with key foo to false
ticket.is "foo" # same as is_foo!
ticket.isnt "foo" # same as isnt_foo!
ticket.has "foo", "bar" # sets interaction with key foo and value bar
ticket.get "foo" # gets the value for the current interaction with key foo
#instance counting methods
# (Most of these count current records with the value set to true.)
event.confirmed_tickets_count # counts number of current interactions on relation 'tickets' with type 'confirmed'
event.confirmed_and_attending_tickets_count # same as above but counts 2 types
event.confirmed_and_not_attending_tickets_count # allows for mixing in "not" to count "false" values
event.all_tickets_counts # returns a hash with all current counts