Class: SocialcastApi::Message
- Defined in:
- lib/socialcast-api/base.rb
Defined Under Namespace
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.search(args = {}) ⇒ Object
18 19 20 |
# File 'lib/socialcast-api/base.rb', line 18 def self.search(args = {}) get(:search, args).map {|| Message.new()} end |
.search_all_pages(args = {}) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/socialcast-api/base.rb', line 22 def self.search_all_pages(args = {}) results = Array.new page = 1 per_page = 500 begin = get(:search, :page => page, :per_page => per_page, :q => args[:q]).map {|| Message.new()} page += 1 results += end until .count < per_page return results end |
Instance Method Details
#flag ⇒ Object
48 49 50 |
# File 'lib/socialcast-api/base.rb', line 48 def flag Message.post(id.to_s + '/flags') end |
#like ⇒ Object
36 37 38 |
# File 'lib/socialcast-api/base.rb', line 36 def like Message.post(id.to_s + '/likes') end |
#unflag ⇒ Object
52 53 54 |
# File 'lib/socialcast-api/base.rb', line 52 def unflag Message.delete(id.to_s + '/flags/' + attributes[:flag].id) end |
#unlike ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/socialcast-api/base.rb', line 40 def unlike likedbyme = likes.select {|alike| alike.unlikable}.first if likedbyme likedbyme. = {:message_id => self.id} likedbyme.destroy end end |