Sha256: bffd1e71b79a42ee9473e4fe473e85ce49606dbd5918d41e69a1b179a4ddac26

Contents?: true

Size: 808 Bytes

Versions: 3

Compression:

Stored size: 808 Bytes

Contents

module Socialcastr

  class Message < Base

    def flag!
      return true if flagged?
      Socialcastr::Flag.new({}, :message_id => id).save
      refresh
    end

    def flagged?
      self.flag && !self.flag.id.nil?
    end

    def unflag!
      return unless flagged?
      self.flag.destroy
      refresh  
    end

    def like!
      Socialcastr::Like.new({}, :message_id => id).save
      refresh
    end

    def unlike!
      self.likes.reject! do |l|
        l.unlikable && l.destroy
      end
    end

    def comment!(arguments={})
      Socialcastr::Comment.new(arguments, :message_id => id).save
      refresh
    end
    

    def self.search(query, arguments={})
      xml = api.get(collection_path + "/search", { :q => query}.merge(arguments))
      return parse(xml)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
socialcastr-0.2.12 lib/socialcastr/message.rb
socialcastr-0.2.11 lib/socialcastr/message.rb
socialcastr-0.2.10 lib/socialcastr/message.rb