Class: Qualtrics::Panel
Instance Attribute Summary collapse
-
#category ⇒ Object
Returns the value of attribute category.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #attributes ⇒ Object
- #destroy ⇒ Object
-
#initialize(options = {}) ⇒ Panel
constructor
A new instance of Panel.
- #save ⇒ Object
Methods inherited from Entity
#configuration, configuration, #get, get, #library_id, #library_id=, #persisted?, post, #post, #success?, underscore_attributes
Constructor Details
#initialize(options = {}) ⇒ Panel
Returns a new instance of Panel.
30 31 32 33 34 35 |
# File 'lib/qualtrics/panel.rb', line 30 def initialize(={}) @name = [:name] @id = [:id] @category = [:category] @library_id = [:library_id] end |
Instance Attribute Details
#category ⇒ Object
Returns the value of attribute category.
7 8 9 |
# File 'lib/qualtrics/panel.rb', line 7 def category @category end |
#id ⇒ Object
Returns the value of attribute id.
7 8 9 |
# File 'lib/qualtrics/panel.rb', line 7 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/qualtrics/panel.rb', line 7 def name @name end |
Class Method Details
.all(library_id = nil) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/qualtrics/panel.rb', line 9 def self.all(library_id = nil) lib_id = library_id || configuration.default_library_id response = get('getPanels', {'LibraryID' => lib_id}) if response.success? response.result['Panels'].map do |panel| new(underscore_attributes(panel)) end else [] end end |
.attribute_map ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/qualtrics/panel.rb', line 21 def self.attribute_map { 'LibraryID' => :library_id, 'Category' => :category, 'Name' => :name, 'PanelID' => :id } end |
Instance Method Details
#attributes ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/qualtrics/panel.rb', line 61 def attributes { 'LibraryID' => library_id, 'Category' => category, 'Name' => name } end |
#destroy ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/qualtrics/panel.rb', line 53 def destroy response = post('deletePanel', { 'LibraryID' => library_id, 'PanelID' => self.id }) response.success? end |
#save ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/qualtrics/panel.rb', line 37 def save response = nil if persisted? raise Qualtrics::UpdateNotAllowed else response = post('createPanel', attributes) end if response.success? self.id = response.result['PanelID'] true else false end end |