Class: Clubhouse::Story
Instance Attribute Summary
Attributes inherited from BaseResource
#client
Class Method Summary
collapse
Instance Method Summary
collapse
attributes, attributes_for_create, attributes_for_update, client, delete, find, #initialize, #reload, resource, #save
Class Method Details
.all ⇒ Object
52
53
54
55
|
# File 'lib/clubhouse/story.rb', line 52
def all
raise NotSupportedByAPIError,
'Use Story.search(..) to return stories matching your search query'
end
|
.search(attr = {}) ⇒ Object
57
58
59
60
|
# File 'lib/clubhouse/story.rb', line 57
def search(attr = {})
payload = client.post("#{endpoint}/search", attr)
payload.collect {|s| new.update_object_from_payload(s) }
end
|
Instance Method Details
28
29
30
31
32
33
34
|
# File 'lib/clubhouse/story.rb', line 28
def (text)
add_resource(:comment) do
= Comment.new(text: text, story_id: id)
.save
<<
end
end
|
#add_task(desc) ⇒ Object
36
37
38
39
40
41
42
|
# File 'lib/clubhouse/story.rb', line 36
def add_task(desc)
add_resource(:task) do
task = Task.new(description: desc, story_id: id)
task.save
tasks << task
end
end
|
#update_object_from_payload(attr = {}) ⇒ Object
44
45
46
47
48
49
|
# File 'lib/clubhouse/story.rb', line 44
def update_object_from_payload(attr = {})
super
instance_variable_set("@_comments", nil)
instance_variable_set("@_tasks", nil)
self
end
|