| Class | EtherpadLite::Group |
| In: |
lib/etherpad-lite/models/group.rb
|
| Parent: | Object |
A Group serves as a container for related pads. Only an Author with a Session can access a group Pad.
Group examples:
# Create a new group
group1 = @ether.create_group
# Etherpad Lite will assign it an internal id
group.id #> 'g.asdflsadf7w9823kjlasdf'
# Create a new group with a mapper, so it can be easily found again
group2 = @ether.create_group :mapper => 'Blurg'
# Load (or create, if it doesn't exist) a group mapped to "Flarb"
group3 = @ether.group('Flarb')
# Load an existing group based on its internal id
group4 = @ether.get_group('g.823lasdlfj98asdfj')
# Create a new pad in this group, optionally specifying its initial text
pad1 = group1.create_pad('group 1 pad', :text => 'Words!')
# Load (or create, if it doesn't exist) a pad in this group
pad2 = group2.pad('group 2 pad')
# Load an existing pad from group 2
pad3 = group2.get_pad('important pad')
Session examples:
# Create two hour-long session for an author in group 1
author = @ether.author('author_1')
session = group1.create_session(author, 60)
Understand how ids work. A group pad‘s id is the group_id + ’$’ + pad_name:
pad2.group_id == group2.id #> true
pad2.id == group2.id + '$' + pad2.name #> true
pad2 == group2.pad('group 2 pad') == @ether.get_pad("#{group2.id}$group 2 pad") == @ether.get_pad('group 2 pad', :groupID => group2.id) #> true
group2.mapper #> "Blurg"
| GROUP_ID_REGEX | = | /^g\.[^\$]+/ |
| id | [R] | The group id |
| instance | [R] | The EtherpadLite::Instance object |
| mapper | [R] | An optional identifier used to map the group to something outside Etherpad Lite |
Creates a new Group. Optionally, you may pass the :mapper option your third party system‘s group id. This will allow you to find your Group again later using the same identifier as your foreign system. If you pass the mapper option, the method behaves like "create group for <mapper> if it doesn‘t already exist".
Options:
mapper => your foreign group id
Instantiates a Group object (presumed it already exists)
Options:
mapper => the foreign id it‘s mapped to
Create a new session for author that will last length_in_minutes.
Returns the Pad with the given id, creating it if it doesn‘t already exist. This requires an HTTP request, so if you know the Pad already exists, use Group#get_pad instead.