Class: Terraspace::Builder::Allow::Region

Inherits:
Base
  • Object
show all
Defined in:
lib/terraspace/builder/allow/region.rb

Instance Method Summary collapse

Methods inherited from Base

#allowed?, #allows, #check!, #denys, #initialize

Methods included from App::CallableOption::Concern

#callable_option

Constructor Details

This class inherits a constructor from Terraspace::Builder::Allow::Base

Instance Method Details

#check_valueObject

interface method



14
15
16
# File 'lib/terraspace/builder/allow/region.rb', line 14

def check_value
  current_region
end

#config_nameObject



23
24
25
26
27
28
29
# File 'lib/terraspace/builder/allow/region.rb', line 23

def config_name
  if config.allow.locations || config.deny.locations
    :locations # ActiveSuport::HashWithIndifferentAccess#dig requires symbol
  else
    super # :regions
  end
end

#current_regionObject



18
19
20
21
# File 'lib/terraspace/builder/allow/region.rb', line 18

def current_region
  expander = Terraspace::Compiler::Expander.autodetect(@mod).expander
  expander.region
end

#messageObject

interface method



4
5
6
7
8
9
10
11
# File 'lib/terraspace/builder/allow/region.rb', line 4

def message
  messages = []
  word = config_name.to_s # IE: regions or locations
  messages << "This #{word.singularize} is not allowed to be used: Detected current #{word.singularize}=#{current_region}"
  messages << "Allow #{word}: #{allows.join(', ')}" if allows
  messages << "Deny #{word}: #{denys.join(', ')}" if denys
  messages.join("\n")
end