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, group) ⇒ ScriptScope

Returns a new instance of ScriptScope.



52
53
54
55
56
57
58
# File 'lib/synco/scope.rb', line 52

def initialize(script, group)
  @script = script
  @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.



63
64
65
# File 'lib/synco/scope.rb', line 63

def current_server
  @current_server
end

#groupObject (readonly)

Returns the value of attribute group.



61
62
63
# File 'lib/synco/scope.rb', line 61

def group
  @group
end

#master_serverObject (readonly)

Returns the value of attribute master_server.



62
63
64
# File 'lib/synco/scope.rb', line 62

def master_server
  @master_server
end

#scriptObject (readonly)

Returns the value of attribute script.



60
61
62
# File 'lib/synco/scope.rb', line 60

def script
  @script
end

Instance Method Details

#callObject



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/synco/scope.rb', line 69

def call
  if @script.running_on_master?
    Console.info(self, "We are the master server...")
  else
    Console.info(self, "We are not the master server...", master: @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
        Console.info(self, "Running backups...", server: @current_server)
        
        run_servers(group)
      end
    end
  end
end

#methodObject



65
66
67
# File 'lib/synco/scope.rb', line 65

def method
  @script.method
end