Class: Pgai::Resources::Local::Environment
Instance Method Summary
collapse
Methods inherited from BaseRecord
all, backend, delete, #delete, find, #klass, record_type, #save
Methods included from Attributes
#assign_attribute, #assign_attributes, #has_attribute?, included, #initialize
Instance Method Details
#client ⇒ Object
15
16
17
18
19
20
|
# File 'lib/pgai/resources/local/environment.rb', line 15
def client
@client ||= Pgai::Client.new(
token: access_token,
host: "http://127.0.0.1:#{local_port}"
)
end
|
#clone_id ⇒ Object
44
45
46
|
# File 'lib/pgai/resources/local/environment.rb', line 44
def clone_id
@clone_id ||= "#{clone_prefix}_#{self.alias}"
end
|
#expected_cloning_time ⇒ Object
36
37
38
|
# File 'lib/pgai/resources/local/environment.rb', line 36
def expected_cloning_time
@expected_cloning_time ||= client.expected_cloning_time
end
|
#local_port ⇒ Object
40
41
42
|
# File 'lib/pgai/resources/local/environment.rb', line 40
def local_port
@local_port ||= Port::Allocator.pick
end
|
#prepare ⇒ Object
22
23
24
25
26
27
28
|
# File 'lib/pgai/resources/local/environment.rb', line 22
def prepare
with_port_forward do
Resources::Remote::BaseRecord.with_client(client) do
yield(self)
end
end
end
|
#with_port_forward(manager = Pgai::Commander.instance.port_manager) ⇒ Object
30
31
32
33
34
|
# File 'lib/pgai/resources/local/environment.rb', line 30
def with_port_forward(manager = Pgai::Commander.instance.port_manager)
manager.forward(local_port, id, port) do
yield self
end
end
|