Sha256: c48900407182bbe437d1c65f6ef0cc299ec9852dace9afa44cd7da43dd7c1002

Contents?: true

Size: 825 Bytes

Versions: 4

Compression:

Stored size: 825 Bytes

Contents

require 'dribbble/utils/findable'

module Dribbble
  class User < Dribbble::Base
    include Dribbble::Utils::Findable

    has_many :buckets, :projects, :shots, :teams
    has_many :likes, as: Dribbble::Shot, key: 'shot'
    has_many :followers, as: Dribbble::User, key: 'follower'
    has_many :following, as: Dribbble::User, key: 'followee'

    def following?(other_user_id = nil)
      if other_user_id
        html_get "/users/#{id}/following/#{other_user_id}"
      else
        html_get "/user/following/#{id}"
      end
      true
    rescue RestClient::ResourceNotFound
      false
    end

    def follow!
      res = html_put "/users/#{id}/follow"
      res.code == 204 ? true : false
    end

    def unfollow!
      res = html_delete "/users/#{id}/follow"
      res.code == 204 ? true : false
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dribbble-1.2.0 lib/dribbble/user.rb
dribbble-1.1.0 lib/dribbble/user.rb
dribbble-1.0.4 lib/dribbble/user.rb
dribbble-1.0.2 lib/dribbble/user.rb