Sha256: 8a4c27eb1577a22281d1c5e0a35d4543e7c638afb13637154e61eab0decfff32

Contents?: true

Size: 870 Bytes

Versions: 6

Compression:

Stored size: 870 Bytes

Contents

require 'dribbble/utils/findable'
require 'dribbble/utils/creatable'
require 'dribbble/utils/updatable'
require 'dribbble/utils/deletable'

module Dribbble
  class Bucket < Dribbble::Base
    include Dribbble::Utils::Findable
    include Dribbble::Utils::Creatable
    include Dribbble::Utils::Updatable
    include Dribbble::Utils::Deletable

    has_many :shots

    def add_shot(shot)
      shot_id = shot.is_a?(Dribbble::Shot) ? shot.id : shot
      res = html_put("/buckets/#{id}/shots") do |payload|
        payload[:shot_id] = shot_id
      end
      res.code == 204 ? true : false
    end

    def remove_shot(shot)
      shot_id = shot.is_a?(Dribbble::Shot) ? shot.id : shot
      res = html_delete "/buckets/#{id}/shots", shot_id: shot_id
      res.code == 204 ? true : false
    end

    def self.available_fields
      %i(name description)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
dribbble-1.2.0 lib/dribbble/bucket.rb
dribbble-1.1.0 lib/dribbble/bucket.rb
dribbble-1.0.4 lib/dribbble/bucket.rb
dribbble-1.0.2 lib/dribbble/bucket.rb
dribbble-1.0.1 lib/dribbble/bucket.rb
dribbble-1.0.0 lib/dribbble/bucket.rb