Class: QualtricsAPI::SurveyCollection
- Inherits:
-
Object
- Object
- QualtricsAPI::SurveyCollection
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- lib/qualtrics_api/survey_collection.rb
Instance Attribute Summary collapse
-
#all ⇒ Object
readonly
Returns the value of attribute all.
-
#scope_id ⇒ Object
Returns the value of attribute scope_id.
Instance Method Summary collapse
- #[](survey_id) ⇒ Object
- #fetch(options = {}) ⇒ Object
- #find(survey_id) ⇒ Object
-
#initialize(options = {}) ⇒ SurveyCollection
constructor
A new instance of SurveyCollection.
- #query_attributes ⇒ Object
- #update_query_attributes(new_attributes = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ SurveyCollection
Returns a new instance of SurveyCollection.
13 14 15 16 17 |
# File 'lib/qualtrics_api/survey_collection.rb', line 13 def initialize( = {}) @conn = [:connection] @scope_id = [:scope_id] @all = [] end |
Instance Attribute Details
#all ⇒ Object (readonly)
Returns the value of attribute all.
8 9 10 |
# File 'lib/qualtrics_api/survey_collection.rb', line 8 def all @all end |
#scope_id ⇒ Object
Returns the value of attribute scope_id.
7 8 9 |
# File 'lib/qualtrics_api/survey_collection.rb', line 7 def scope_id @scope_id end |
Instance Method Details
#[](survey_id) ⇒ Object
36 |
# File 'lib/qualtrics_api/survey_collection.rb', line 36 def [](survey_id); find(survey_id); end |
#fetch(options = {}) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/qualtrics_api/survey_collection.rb', line 19 def fetch( = {}) @all = [] update_query_attributes() parse_fetch_response(@conn.get('surveys', query_params)) self end |
#find(survey_id) ⇒ Object
37 38 39 40 41 |
# File 'lib/qualtrics_api/survey_collection.rb', line 37 def find(survey_id) @all.select do |survey| survey.id == survey_id end.first || QualtricsAPI::Survey.new("id" => survey_id , connection: @conn) end |
#query_attributes ⇒ Object
26 27 28 29 30 |
# File 'lib/qualtrics_api/survey_collection.rb', line 26 def query_attributes { :scope_id => @scope_id } end |
#update_query_attributes(new_attributes = {}) ⇒ Object
32 33 34 |
# File 'lib/qualtrics_api/survey_collection.rb', line 32 def update_query_attributes(new_attributes = {}) @scope_id = new_attributes[:scope_id] if new_attributes.has_key? :scope_id end |