Sha256: 51ca385f8a1ee3b40cc06d71d9e30a7e9701244336d7d22ed4e6523d35824d44
Contents?: true
Size: 1.63 KB
Versions: 7
Compression:
Stored size: 1.63 KB
Contents
class Fluentd module Setting class OutForward class Server include Common KEYS = [ :name, :host, :port, :weight, :standby ].freeze attr_accessor(*KEYS) flags :standby validates :host, presence: true validates :port, presence: true end class Secondary include Common KEYS = [ :type, :path ].freeze attr_accessor(*KEYS) hidden :type validates :path, presence: true end include Common KEYS = [ :match, :send_timeout, :recover_wait, :heartbeat_type, :heartbeat_interval, :phi_threshold, :hard_timeout, :server, :secondary ].freeze attr_accessor(*KEYS) choice :heartbeat_type, %w(udp tcp) nested :server, Server, multiple: true nested :secondary, Secondary validates :match, presence: true validate :validate_has_at_least_one_server validate :validate_nested_values def validate_has_at_least_one_server if children_of(:server).reject{|s| s.empty_value? }.blank? errors.add(:base, :out_forward_blank_server) end end def validate_nested_values self.class.children.inject(true) do |result, (key, _)| children_of(key).each do |child| if !child.empty_value? && !child.valid? child.errors.full_messages.each do |message| errors.add(:base, "(#{key})#{message}") end result = false end result end result end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems