Class: EPC::Command::UpdateRoleCommand

Inherits:
UpdateCommand show all
Defined in:
lib/epc/command/role/update_role_command.rb

Constant Summary

Constants inherited from BaseCommand

BaseCommand::GIVEUP_TICKS, BaseCommand::SLEEP_TIME, BaseCommand::TICKER_TICKS

Instance Attribute Summary

Attributes inherited from BaseCommand

#client, #klass_name, #object_id, #object_type, #options, #target_id, #target_type

Instance Method Summary collapse

Methods inherited from BaseCommand

#check_options, #context_params, #context_params=, #go, include_module, inherited, #initialize, required_options, #say_err

Methods included from PersistentAttributes

#auth_token, #caller_id, #target_url

Constructor Details

This class inherits a constructor from EPC::Command::BaseCommand

Instance Method Details

#execute(args = []) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/epc/command/role/update_role_command.rb', line 6

def execute(args = [])
  require_object
  role_id = object_id

  if @options[:file].present?
    data = EPC::Config.read_content_as_json(@options[:file])
    batch_add(object_id, data)
  end

  if @options[:add_user].present?
    status = add_user(role_id, @options[:add_user])
  end

  if @options[:remove_user].present?
    status = remove_user(role_id, @options[:remove_user])
  end

  if @options[:add_group].present?
    status = add_group(role_id, @options[:add_group])
  end


  if @options[:remove_group].present?
    status = remove_group(role_id, @options[:remove_group])
  end

  if @options[:add_grant].present?
    status = add_grant(role_id, @options[:add_grant])
  end

  if @options[:remove_grant].present?
    status = remove_grant(role_id, @options[:remove_grant])
  end

  return status
end