Files
ubicloud/serializers/load_balancer.rb
Jeremy Evans f721c31c55 Avoid the use of serializers for the load balancer show template
This allows us to remove the :load_balancer option from the VM
serializer and the :vms_serialized option from the LoadBalancer
serializer.

Add some model methods for code that was previously in the
serializers.

To a better job of testing for expected values on the load
balancer show page, instead of using the non-specific
have_content for everything.
2025-08-08 01:52:14 +09:00

30 lines
692 B
Ruby

# frozen_string_literal: true
class Serializers::LoadBalancer < Serializers::Base
def self.serialize_internal(lb, options = {})
base = {
id: lb.ubid,
name: lb.name,
location: lb.display_location,
hostname: lb.hostname,
algorithm: lb.algorithm,
stack: lb.stack,
health_check_endpoint: lb.health_check_endpoint,
health_check_protocol: lb.health_check_protocol,
src_port: lb.src_port,
dst_port: lb.dst_port
}
if options[:include_path]
base[:path] = lb.path
end
if options[:detailed]
base[:subnet] = lb.private_subnet.name
base[:vms] = lb.vms.map { it.ubid } || []
end
base
end
end