Class: Konzertmeister::InfrastructureVersion

Inherits:
Object
  • Object
show all
Defined in:
lib/konzertmeister/infrastructure_version.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data = {}) ⇒ InfrastructureVersion

Returns a new instance of InfrastructureVersion.



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/konzertmeister/infrastructure_version.rb', line 5

def initialize(data = {})
  @data = data
  data.each do |k,value|
    if m = k.match(/^infrastructure_version_id$/)
      key = "id"
    else
      key = k
    end

    instance_variable_set("@#{key}", value)
  end
end

Instance Attribute Details

#branchObject

Returns the value of attribute branch.



3
4
5
# File 'lib/konzertmeister/infrastructure_version.rb', line 3

def branch
  @branch
end

#commitObject

Returns the value of attribute commit.



3
4
5
# File 'lib/konzertmeister/infrastructure_version.rb', line 3

def commit
  @commit
end

#created_atObject (readonly)

Returns the value of attribute created_at.



3
4
5
# File 'lib/konzertmeister/infrastructure_version.rb', line 3

def created_at
  @created_at
end

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/konzertmeister/infrastructure_version.rb', line 3

def id
  @id
end

#tagObject

Returns the value of attribute tag.



3
4
5
# File 'lib/konzertmeister/infrastructure_version.rb', line 3

def tag
  @tag
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



3
4
5
# File 'lib/konzertmeister/infrastructure_version.rb', line 3

def updated_at
  @updated_at
end

Instance Method Details

#saveObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/konzertmeister/infrastructure_version.rb', line 18

def save
  if commit
    params = { 'commit' => commit }
  elsif tag
    params = { 'tag' => tag }
  elsif branch
    params = { 'branch' => branch }
  end

  response = Konzertmeister.session.post('/infrastructure_versions', params)
  if response
    response_object = Konzertmeister::InfrastructureVersion.new(response)
    @id = response_object.id
    response_object
  end
end

#to_sObject



53
54
55
56
57
58
59
60
61
62
63
# File 'lib/konzertmeister/infrastructure_version.rb', line 53

def to_s
  if @data.has_key?("commit")
    inf_version_string = "commit:#{@data["commit"]}"
  elsif @data.has_key?("tag")
    inf_version_string = "tag:#{@data["tag"]}"
  else
    inf_version_string = "branch:#{@data["branch"]}"
  end

  "Inf<#{inf_version_string}>"
end