Class: Terraspace::Builder::Allow::Base
- Inherits:
-
Object
- Object
- Terraspace::Builder::Allow::Base
- Includes:
- App::CallableOption::Concern
- Defined in:
- lib/terraspace/builder/allow/base.rb
Instance Method Summary collapse
- #allowed? ⇒ Boolean
- #allows ⇒ Object
- #check! ⇒ Object
- #denys ⇒ Object
-
#initialize(mod) ⇒ Base
constructor
A new instance of Base.
Methods included from App::CallableOption::Concern
Constructor Details
#initialize(mod) ⇒ Base
Returns a new instance of Base.
5 6 7 8 |
# File 'lib/terraspace/builder/allow/base.rb', line 5 def initialize(mod) @mod = mod # Only Region subclass uses @mod but keeping interface same for Env for simplicity @stack_name = mod.name end |
Instance Method Details
#allowed? ⇒ Boolean
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/terraspace/builder/allow/base.rb', line 22 def allowed? if allows.nil? && denys.nil? true elsif denys.nil? allows.include?(check_value) elsif allows.nil? !denys.include?(check_value) else allows.include?(check_value) && !denys.include?(check_value) end end |
#allows ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/terraspace/builder/allow/base.rb', line 34 def allows callable_option( config_name: "config.allow.#{config_name}", config_value: config.dig(:allow, config_name), passed_args: [@stack_name], ) end |
#check! ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/terraspace/builder/allow/base.rb', line 10 def check! = [] unless allowed? << # message is interface method end unless .empty? puts "ERROR: The configs do not allow this.".color(:red) puts exit 1 end end |
#denys ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/terraspace/builder/allow/base.rb', line 42 def denys callable_option( config_name: "config.deny.#{config_name}", config_value: config.dig(:deny, config_name), passed_args: [@stack_name], ) end |