Sha256: c19b322eee6975813f0f88112888196ea0c7ee0c3dbbbce300cefdbdb6aa9316

Contents?: true

Size: 758 Bytes

Versions: 3

Compression:

Stored size: 758 Bytes

Contents

module Socialcastr
  class Comment < Base
    element :editable
    elements :attachment, :as => :attachments, :class => Socialcastr::Attachment
    element :likable
    element :deletable
    elements :like, :as => :likes, :class => Socialcastr::Like
    element :permalink_url
    element :text
    element :user, :class => Socialcastr::User
    element :thumbnail_url
    element :url
    element :likes_count
    element :"created-at", :as => :created_at
    element :id

    def unlikable_by?(api_id)
      self.likes.map{|l| l.unlikable_by?(api_id)}.any?
    end
    
    def likable_by?(api_id)
      self.user_id  != api_id
    end
    
    def like_id(api_id)
      self.likes.select { |like| like.unlikable_by?(api_id) }.first.id
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
socialcastr-0.1.3 lib/socialcastr/comment.rb
socialcastr-0.1.2 lib/socialcastr/comment.rb
socialcastr-0.1.1 lib/socialcastr/comment.rb