Class: Deploy::ServerGroup

Inherits:
Resource show all
Defined in:
lib/deploy/resources/server_group.rb

Instance Attribute Summary

Attributes inherited from Resource

#attributes, #errors, #id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

class_name, #create, #destroy, find, find_all, find_single, #method_missing, #new_record?, post, #post, #respond_to_missing?, #save, #update

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Deploy::Resource

Class Method Details

.collection_path(params = {}) ⇒ Object



8
9
10
# File 'lib/deploy/resources/server_group.rb', line 8

def collection_path(params = {})
  "projects/#{params[:project].permalink}/server_groups"
end

.member_path(_id, params = {}) ⇒ Object



12
13
14
# File 'lib/deploy/resources/server_group.rb', line 12

def member_path(_id, params = {})
  "projects/#{params[:project].permalink}/server_groups/#{identifier}"
end

Instance Method Details

#default_paramsObject



18
19
20
# File 'lib/deploy/resources/server_group.rb', line 18

def default_params
  { project: project }
end

#serversObject



22
23
24
# File 'lib/deploy/resources/server_group.rb', line 22

def servers
  @servers ||= attributes['servers'].map { |server_attr| Deploy::Server.send(:create_object, server_attr) }
end

#to_sObject



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/deploy/resources/server_group.rb', line 26

def to_s
  [].tap do |a|
    a << name
    a << "(branch: #{preferred_branch})" if preferred_branch
    if last_revision
      a << "(currently: #{last_revision})"
    else
      a << '(currently undeployed)'
    end
  end.join(' ')
end