Class: Socialcastr::Message
- Inherits:
-
Base
- Object
- Base
- Socialcastr::Message
show all
- Defined in:
- lib/socialcastr/message.rb
Instance Attribute Summary
Attributes inherited from Base
#prefix_options
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, #destroy, #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, #refresh, #save, set_prefix_options, #to_params, #to_prefix_options, #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
48
49
50
51
|
# File 'lib/socialcastr/message.rb', line 48
def self.search(query, arguments={})
xml = api.get(collection_path + "/search", { :q => query}.merge(arguments))
return parse(xml)
end
|
Instance Method Details
42
43
44
45
|
# File 'lib/socialcastr/message.rb', line 42
def (arguments={})
Socialcastr::Comment.new(arguments, :message_id => id).save
refresh
end
|
#flag! ⇒ Object
5
6
7
8
9
|
# File 'lib/socialcastr/message.rb', line 5
def flag!
return true if flagged?
Socialcastr::Flag.new({}, :message_id => id).save
refresh
end
|
#flagged? ⇒ Boolean
11
12
13
|
# File 'lib/socialcastr/message.rb', line 11
def flagged?
self.flag && !self.flag.id.nil?
end
|
#likable_by?(api_id) ⇒ Boolean
26
27
28
29
|
# File 'lib/socialcastr/message.rb', line 26
def likable_by?(api_id)
return false if self.user.id == api_id
like_for(api_id).nil?
end
|
#like! ⇒ Object
21
22
23
24
|
# File 'lib/socialcastr/message.rb', line 21
def like!
Socialcastr::Like.new({}, :message_id => id).save
refresh
end
|
#like_for(api_id) ⇒ Object
31
32
33
34
|
# File 'lib/socialcastr/message.rb', line 31
def like_for(api_id)
return nil if (self.likes.nil? || self.likes.empty?)
self.likes.select { |like| like.unlikable_by?(api_id) }.first
end
|
#unflag! ⇒ Object
15
16
17
18
19
|
# File 'lib/socialcastr/message.rb', line 15
def unflag!
return unless flagged?
self.flag.destroy
refresh
end
|
#unlike! ⇒ Object
36
37
38
39
40
|
# File 'lib/socialcastr/message.rb', line 36
def unlike!
self.likes.reject! do |l|
l.unlikable && l.destroy
end
end
|