Class: Banacle::SlashCommand::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/banacle/slash_command/command.rb

Constant Summary collapse

CREATE_ACTION =
'create'.freeze
DELETE_ACTION =
'delete'.freeze
PERMITTED_ACTIONS =
[CREATE_ACTION, DELETE_ACTION].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(action:, region:, vpc_id:, cidr_blocks:) ⇒ Command

Returns a new instance of Command.



12
13
14
15
16
17
# File 'lib/banacle/slash_command/command.rb', line 12

def initialize(action:, region:, vpc_id:, cidr_blocks:)
  @action = action
  @region = region
  @vpc_id = vpc_id
  @cidr_blocks = cidr_blocks
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



19
20
21
# File 'lib/banacle/slash_command/command.rb', line 19

def action
  @action
end

#cidr_blocksObject (readonly)

Returns the value of attribute cidr_blocks.



19
20
21
# File 'lib/banacle/slash_command/command.rb', line 19

def cidr_blocks
  @cidr_blocks
end

#regionObject (readonly)

Returns the value of attribute region.



19
20
21
# File 'lib/banacle/slash_command/command.rb', line 19

def region
  @region
end

#vpc_idObject (readonly)

Returns the value of attribute vpc_id.



19
20
21
# File 'lib/banacle/slash_command/command.rb', line 19

def vpc_id
  @vpc_id
end

Instance Method Details

#executeObject



21
22
23
24
25
26
27
28
29
30
# File 'lib/banacle/slash_command/command.rb', line 21

def execute
  case action
  when CREATE_ACTION
    create_nacl
  when DELETE_ACTION
    delete_nacl
  else
    # Do nothing
  end
end

#to_hObject



32
33
34
35
36
37
38
39
# File 'lib/banacle/slash_command/command.rb', line 32

def to_h
  {
    action: action,
    region: region,
    vpc_id: vpc_id,
    cidr_blocks: cidr_blocks,
  }
end