Class: Deploy::Deployment

Inherits:
Resource show all
Defined in:
lib/deploy/resources/deployment.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/deployment.rb', line 8

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

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



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

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

Instance Method Details

#default_paramsObject



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

def default_params
  { project: project }
end

#projectObject



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

def project
  attributes['project'] = Project.send(:create_object, attributes['project']) if attributes['project'].is_a?(Hash)
  attributes['project']
end

#serversObject



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

def servers
  if attributes['servers'].is_a?(Array)
    @servers ||= attributes['servers'].map do |server_params|
      Server.new.tap do |server|
        server.id = server_params['id']
        server.attributes = server_params
      end
    end
  else
    []
  end
end

#stepsObject



40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/deploy/resources/deployment.rb', line 40

def steps
  if attributes['steps'].is_a?(Array)
    @steps ||= attributes['steps'].map do |step_params|
      DeploymentStep.new.tap do |step|
        step.id = step_params['identifier']
        step.attributes = step_params
        step.attributes['deployment'] = self
      end
    end
  else
    []
  end
end