Class: Amaranth::Project

Inherits:
Struct
  • Object
show all
Defined in:
lib/amaranth/project.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Project

Returns a new instance of Project.



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

def initialize attributes={}
  attributes.each do |key, value|
    self[key] = value
  end
end

Instance Attribute Details

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



4
5
6
# File 'lib/amaranth/project.rb', line 4

def name
  @name
end

#slugObject

Returns the value of attribute slug

Returns:

  • (Object)

    the current value of slug



4
5
6
# File 'lib/amaranth/project.rb', line 4

def slug
  @slug
end

#team_slugObject

Returns the value of attribute team_slug

Returns:

  • (Object)

    the current value of team_slug



4
5
6
# File 'lib/amaranth/project.rb', line 4

def team_slug
  @team_slug
end

Class Method Details

.all(team_slug:) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/amaranth/project.rb', line 5

def self.all team_slug:
  Request.get("/api/teams/#{team_slug}/projects/")["objects"].map do |attributes|
    attributes = attributes.keep_if { |key, value| members.include? key.to_sym }
    attributes["team_slug"] = team_slug
    new attributes
  end
end

.create(attributes) ⇒ Object



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

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



13
14
15
# File 'lib/amaranth/project.rb', line 13

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

.find(team_slug:, slug:) ⇒ Object



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

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

Instance Method Details

#videosObject



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

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