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, #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



5
6
7
# File 'lib/deploy/resources/server_group.rb', line 5

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

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



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

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

Instance Method Details

#default_paramsObject



14
15
16
# File 'lib/deploy/resources/server_group.rb', line 14

def default_params
  {:project => self.project}
end

#serversObject



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

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

#to_sObject



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/deploy/resources/server_group.rb', line 22

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