Class: Applb::DSL::EC2::LoadBalancer::Listeners::Listener::Result
- Inherits:
-
Object
- Object
- Applb::DSL::EC2::LoadBalancer::Listeners::Listener::Result
- Defined in:
- lib/applb/dsl/listener.rb
Constant Summary collapse
- ATTRIBUTES =
%i/certificates ssl_policy port protocol default_actions rules load_balancer_arn/
Instance Method Summary collapse
- #aws(aws_listener) ⇒ Object
- #create ⇒ Object
-
#initialize(context, lb_name) ⇒ Result
constructor
A new instance of Result.
- #modify ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(context, lb_name) ⇒ Result
Returns a new instance of Result.
18 19 20 21 22 |
# File 'lib/applb/dsl/listener.rb', line 18 def initialize(context, lb_name) @context = context @options = context. @lb_name = lb_name end |
Instance Method Details
#aws(aws_listener) ⇒ Object
28 29 30 31 |
# File 'lib/applb/dsl/listener.rb', line 28 def aws(aws_listener) @aws_listener = aws_listener self end |
#create ⇒ Object
33 34 35 36 37 |
# File 'lib/applb/dsl/listener.rb', line 33 def create Applb.logger.info("#{@lb_name} Create listener for port #{port}") return if @options[:dry_run] client.create_listener(create_option).listeners.first end |
#modify ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/applb/dsl/listener.rb', line 39 def modify dsl_hash = to_diff_h aws_hash = to_diff_h_aws return if dsl_hash == aws_hash Applb.logger.info("#{@lb_name} Modify listener for port #{port}") Applb.logger.info("<diff>\n#{Applb::Utils.diff(aws_hash, dsl_hash, color: @options[:color])}") return if @options[:dry_run] client.modify_listener(modify_option).listeners.first end |
#to_h ⇒ Object
24 25 26 |
# File 'lib/applb/dsl/listener.rb', line 24 def to_h Hash[ATTRIBUTES.sort.map { |name| [name, public_send(name)] }] end |