Class: Amaranth::Project

Inherits:
Collection show all
Defined in:
lib/amaranth/project.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Collection

#==, #attributes, #attributes=, field, fields, #initialize

Constructor Details

This class inherits a constructor from Amaranth::Collection

Class Method Details

.all(team_slug:) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/amaranth/project.rb', line 9

def self.all team_slug:
  url = "/api/teams/#{team_slug}/projects/?limit=100"
  fetch(url).map do |attributes|
    attributes = attributes.keep_if { |key, value| fields.include? key.to_sym }
    attributes["team_slug"] = team_slug
    new attributes
  end
end

.create(attributes) ⇒ Object



22
23
24
25
26
27
# File 'lib/amaranth/project.rb', line 22

def self.create attributes
  team_slug = attributes.delete(:team_slug)
  if Request.post("/api/teams/#{team_slug}/projects/", attributes)
    new attributes
  end
end

.delete(team_slug:, slug:) ⇒ Object



18
19
20
# File 'lib/amaranth/project.rb', line 18

def self.delete team_slug:, slug:
  Request.delete("/api/teams/#{team_slug}/projects/#{slug}/")
end

.find(team_slug:, slug:) ⇒ Object



29
30
31
# File 'lib/amaranth/project.rb', line 29

def self.find team_slug:, slug:
  all(team_slug: team_slug).find { |project| project.slug == slug }
end

Instance Method Details

#videosObject



33
34
35
# File 'lib/amaranth/project.rb', line 33

def videos
  Video.all(team_slug: team_slug, project_slug: slug)
end