Class: Synco::ScriptScope

Inherits:
Object
  • Object
show all
Defined in:
lib/synco/scope.rb

Direct Known Subclasses

TargetScope

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(script, logger, group) ⇒ ScriptScope

Returns a new instance of ScriptScope.



79
80
81
82
83
84
85
86
# File 'lib/synco/scope.rb', line 79

def initialize(script, logger, group)
	@script = script
	@logger = logger
	@group = group
	
	@current_server = ServerScope.new(@script.current_server, self)
	@master_server = ServerScope.new(@script.master_server, self, @current_server)
end

Instance Attribute Details

#current_serverObject (readonly)

Returns the value of attribute current_server.



92
93
94
# File 'lib/synco/scope.rb', line 92

def current_server
  @current_server
end

#groupObject (readonly)

Returns the value of attribute group.



90
91
92
# File 'lib/synco/scope.rb', line 90

def group
  @group
end

#loggerObject (readonly)

Returns the value of attribute logger.



89
90
91
# File 'lib/synco/scope.rb', line 89

def logger
  @logger
end

#master_serverObject (readonly)

Returns the value of attribute master_server.



91
92
93
# File 'lib/synco/scope.rb', line 91

def master_server
  @master_server
end

#scriptObject (readonly)

Returns the value of attribute script.



88
89
90
# File 'lib/synco/scope.rb', line 88

def script
  @script
end

Instance Method Details

#callObject



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/synco/scope.rb', line 98

def call
	if @script.running_on_master?
		logger.info "We are the master server..."
	else
		logger.info "We are not the master server..."
		logger.info "Master server is #{@master}..."
	end

	@script.try(self) do
		# This allows events to run on the master server if specified, before running any backups.
		
		@master_server.try(master_target_server) do
			method.try(self) do
				logger.info "Running backups for server #{@current_server}..."
				
				run_servers(group)
			end
		end
	end
end

#methodObject



94
95
96
# File 'lib/synco/scope.rb', line 94

def method
	@script.method
end