Module: EtherpadLite::Padded

Included in:
Group, Instance
Defined in:
lib/etherpad-lite/models/padded.rb

Overview

Methods for dealing with pads belonging to something. Both Instance and Group include this, as they each have pads. This will work with any object which has an instance method, returning an EtherpadLite Instance object.

Instance Method Summary collapse

Instance Method Details

#create_pad(id, options = {}) ⇒ Object

Creates and returns a Pad with the given id.

Options:

text => ‘initial Pad text’



27
28
29
# File 'lib/etherpad-lite/models/padded.rb', line 27

def create_pad(id, options={})
  Pad.create instance, id, options
end

#get_pad(id, options = {}) ⇒ Object

Returns the Pad with the given id (presumed to already exist). Use this instead of Instance#pad when you know the Pad already exists; it will save an HTTP request.



18
19
20
# File 'lib/etherpad-lite/models/padded.rb', line 18

def get_pad(id, options={})
  Pad.new instance, id, options
end

#pad(id, options = {}) ⇒ Object

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 Instance#get_pad instead.



7
8
9
10
11
12
13
14
# File 'lib/etherpad-lite/models/padded.rb', line 7

def pad(id, options={})
  begin
    Pad.create(instance, id, options)
  # Pad alreaded exists
  rescue Error
    Pad.new(instance, id, options)
  end
end