Module: Capistrano::RpushPlugin::Common

Included in:
Capistrano::Rpush
Defined in:
lib/capistrano/rpush/common.rb

Instance Method Summary collapse

Instance Method Details

#rpush_switch_user(role, &block) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/capistrano/rpush/common.rb', line 5

def rpush_switch_user role, &block
  user = rpush_user role
  if user == role.user
    block.call
  else
    as user do
      block.call
    end
  end
end

#rpush_user(role) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/capistrano/rpush/common.rb', line 16

def rpush_user role
  properties = role.properties
  properties.fetch(:rpush_user) ||  # local property for rpush only
  fetch(:rpush_user) ||
  properties.fetch(:run_as) ||      # global property across multiple capistrano gems
  role.user
end