Class: Whoa::Experiment
Constant Summary
collapse
- Url =
"https://www.google.com/analytics/feeds/websiteoptimizer/experiments"
Instance Attribute Summary
Attributes inherited from WoObject
#new_record
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from WoObject
all, #attributes, #copy!, create, #destroy, first, handle_response, inherited, #initialize, last, #merge_attributes, #new_record?, #save, #update_attributes
Constructor Details
This class inherits a constructor from Whoa::WoObject
Class Method Details
.find(exp_id) ⇒ Object
42
43
44
45
46
47
|
# File 'lib/whoa/experiment.rb', line 42
def self.find(exp_id)
Whoa::Request.get(url(exp_id)) do |response|
return if response.code == 401 parse(response.body)
end
end
|
Instance Method Details
#all ⇒ Object
64
65
66
|
# File 'lib/whoa/experiment.rb', line 64
def all
Feed.all.experiments
end
|
#create_page(opts) ⇒ Object
29
30
31
32
|
# File 'lib/whoa/experiment.rb', line 29
def create_page(opts)
opts.merge!({:experiment_id => experiment_id})
Whoa::Page.create(opts)
end
|
#pages ⇒ Object
25
26
27
|
# File 'lib/whoa/experiment.rb', line 25
def pages
Whoa::Feed.all_pages(experiment_id)
end
|
#start! ⇒ Object
38
39
40
|
# File 'lib/whoa/experiment.rb', line 38
def start!
update_attributes(:status => 'Running')
end
|
#stop! ⇒ Object
34
35
36
|
# File 'lib/whoa/experiment.rb', line 34
def stop!
update_attributes(:status => 'Finished')
end
|
#to_xml ⇒ Object
TODO: remove all default account stuff
56
57
58
59
60
61
62
|
# File 'lib/whoa/experiment.rb', line 56
def to_xml
Whoa::Request.build_payload do |xml|
xml.title title
xml.gwo :experimentType, 'AB'
xml.gwo :status, status
end
end
|
#url ⇒ Object
49
50
51
52
53
|
# File 'lib/whoa/experiment.rb', line 49
def url
str = Url
str += "/#{experiment_id}" unless new_record?
str
end
|