Class: Caseblocks::BucketGroup

Inherits:
Object
  • Object
show all
Defined in:
lib/caseblocks/bucket_group.rb

Overview

Since:

  • 0.1.0

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bucket_group_data, client) ⇒ BucketGroup

Returns a new instance of BucketGroup.

Since:

  • 0.1.0



14
15
16
17
# File 'lib/caseblocks/bucket_group.rb', line 14

def initialize(bucket_group_data, client)
  @client = client
  @bucket_group_data = bucket_group_data
end

Class Method Details

.all(client) ⇒ Object

Since:

  • 0.1.0



4
5
6
7
# File 'lib/caseblocks/bucket_group.rb', line 4

def self.all(client)
  res = client.new.request("/case_blocks/bucket_groups.json")
  res["bucket_groups"].map{|bg| Caseblocks::BucketGroup.new(bg, client)}
end

.find(id, client) ⇒ Object

Since:

  • 0.1.0



9
10
11
12
# File 'lib/caseblocks/bucket_group.rb', line 9

def self.find(id, client)
  res = client.request("/case_blocks/bucket_group/#{id}.json")
  return Bucket.new(res["bucket_group"], client)
end

Instance Method Details

#bucketsObject

Since:

  • 0.1.0



23
24
25
26
# File 'lib/caseblocks/bucket_group.rb', line 23

def buckets
  query = @bucket_group_data["buckets"].map{|id| "ids%5B%5D=#{id}" }.join("&")
  @buckets ||= @client.request("/case_blocks/buckets.json?#{query}")["buckets"].map{|bucket| Caseblocks::Bucket.new(bucket, client) }
end

#nameObject

Since:

  • 0.1.0



19
20
21
# File 'lib/caseblocks/bucket_group.rb', line 19

def name
  @bucket_group_data["name"]
end