Sha256: fadb21f9aa86a873aa32e2a6556c4010e64f2755bfad94fe9e23d3658a0a6e44

Contents?: true

Size: 1.53 KB

Versions: 6

Compression:

Stored size: 1.53 KB

Contents

require 'contracts'

module Path53
  module Feature
    module AliasTargets
      include ::Contracts::Core
      include ::Contracts::Builtin

      EvaluateTargetHealth = Or[
        Bool,
        KeywordArgs[evaluate_target_health: Bool],
      ]

      LoadBalancer = RespondTo[:canonical_hosted_zone_name_id, :canonical_hosted_zone_name]

      AliasTarget = ({
                       hosted_zone_id: String,
                       dns_name: String,
                       evaluate_target_health: Bool
                     })

      Contract None => Func[EvaluateTargetHealth => Bool]
      def evaluate_target_health
        ->(value) { evaluate_target_health value }
      end

      Contract Maybe[Bool] => Bool
      def evaluate_target_health(value = false)
        value || false
      end

      Contract KeywordArgs[evaluate_target_health: Bool] => Bool
      def evaluate_target_health(options)
        evaluate_target_health options.fetch :evaluate_target_health
      end

      Contract String, String, Maybe[EvaluateTargetHealth] => AliasTarget
      def alias_target(zone, name, check = nil)
        {
          hosted_zone_id: zone,
          dns_name: name,
          evaluate_target_health: evaluate_target_health(check)
        }
      end

      Contract LoadBalancer, Maybe[EvaluateTargetHealth] => AliasTarget
      def alias_target(load_balancer, check = nil)
        alias_target(
          load_balancer.canonical_hosted_zone_name_id,
          load_balancer.canonical_hosted_zone_name,
          check
        )
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
path53-0.4.14 lib/path53/feature/alias_targets.rb
path53-0.4.8 lib/path53/feature/alias_targets.rb
path53-0.4.7 lib/path53/feature/alias_targets.rb
path53-0.4.6 lib/path53/feature/alias_targets.rb
path53-0.4.4 lib/path53/feature/alias_targets.rb
path53-0.4.3 lib/path53/feature/alias_targets.rb