Class: Amaranth::Project
- Inherits:
-
Struct
- Object
- Struct
- Amaranth::Project
- Defined in:
- lib/amaranth/project.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#slug ⇒ Object
Returns the value of attribute slug.
-
#team_slug ⇒ Object
Returns the value of attribute team_slug.
Class Method Summary collapse
- .all(team_slug:) ⇒ Object
- .create(attributes) ⇒ Object
- .delete(team_slug:, slug:) ⇒ Object
- .find(team_slug:, slug:) ⇒ Object
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Project
constructor
A new instance of Project.
- #videos ⇒ Object
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
#name ⇒ Object
Returns the value of attribute name
4 5 6 |
# File 'lib/amaranth/project.rb', line 4 def name @name end |
#slug ⇒ Object
Returns the value of attribute slug
4 5 6 |
# File 'lib/amaranth/project.rb', line 4 def slug @slug end |
#team_slug ⇒ Object
Returns the value of attribute 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 |