Class: Socialcastr::Message
- Inherits:
-
Base
- Object
- Base
- Socialcastr::Message
show all
- Defined in:
- lib/socialcastr/message.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
all, api, #api, collection_name, #collection_path, collection_path, #copy_attributes_from_object, #create, #element_path, element_path, find, find_every, find_single, first, from_hash, #id, #initialize, last, #method_missing, #method_name, model_name, #new?, #param_name, parse, parse_options, prefix, #save, #to_params, #update
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Socialcastr::Base
Class Method Details
.search(query, arguments = {}) ⇒ Object
37
38
39
40
41
42
|
# File 'lib/socialcastr/message.rb', line 37
def self.search(query, arguments={})
puts "searching for #{query}"
xml = api.get(collection_path + "/search", { :q => query}.merge(arguments))
puts "Got a response xml of #{xml.length} bytes"
return parse(xml)
end
|
Instance Method Details
31
32
33
34
|
# File 'lib/socialcastr/message.rb', line 31
def (arguments={})
= Socialcastr::Comment.new(arguments)
api.post(element_path + "/comments", .to_params)
end
|
#flag! ⇒ Object
5
6
7
8
|
# File 'lib/socialcastr/message.rb', line 5
def flag!
return true if flagged?
self.flag = Socialcastr::Flag.parse(api.post(element_path + "/flags"))
end
|
10
11
12
|
# File 'lib/socialcastr/message.rb', line 10
def flagged?
self.flag && !self.flag.id.nil?
end
|
#like! ⇒ Object
20
21
22
23
|
# File 'lib/socialcastr/message.rb', line 20
def like!
self.likes ||= []
likes << Like.parse(api.post(element_path + "/likes"))
end
|
#unflag! ⇒ Object
14
15
16
17
18
|
# File 'lib/socialcastr/message.rb', line 14
def unflag!
return unless flagged?
api.delete(element_path + "/flags/#{self.flag.id}")
self.flag = nil
end
|
#unlike! ⇒ Object
25
26
27
28
29
|
# File 'lib/socialcastr/message.rb', line 25
def unlike!
self.likes.reject! do |l|
l.unlikable && api.delete(element_path + "/likes/#{l.id}")
end
end
|