module Avro::Builder::Types::NamedErrorHandling

This concern provides error handling for attributes related to naming that are handled differently at the top-level vs inline.

Public Instance Methods

type_name(_value) click to toggle source

Errors for attributes specified via block

# File lib/avro/builder/types/named_error_handling.rb, line 13
def type_name(_value)
  name_attribute_error!
end
type_namespace(_value) click to toggle source
# File lib/avro/builder/types/named_error_handling.rb, line 17
def type_namespace(_value)
  namespace_attribute_error!
end

Private Instance Methods

name=(_value) click to toggle source

Errors for misnamed options

# File lib/avro/builder/types/named_error_handling.rb, line 25
def name=(_value)
  type_name_instead_of_name_error!
end
name_attribute_error!() click to toggle source
# File lib/avro/builder/types/named_error_handling.rb, line 40
def name_attribute_error!
  specify_as_type_option_error!(:name)
end
namespace=(_value) click to toggle source
# File lib/avro/builder/types/named_error_handling.rb, line 29
def namespace=(_value)
  type_namespace_instead_of_namespace_error!
end
namespace_attribute_error!() click to toggle source
# File lib/avro/builder/types/named_error_handling.rb, line 44
def namespace_attribute_error!
  specify_as_type_option_error!(:namespace)
end
specify_as_type_option_error!(name) click to toggle source

Methods to raise errors

# File lib/avro/builder/types/named_error_handling.rb, line 35
def specify_as_type_option_error!(name)
  raise AttributeError
    .new("'type_#{name}' must be specified as an option, not via a block")
end
type_name_instead_of_name_error!() click to toggle source
# File lib/avro/builder/types/named_error_handling.rb, line 53
def type_name_instead_of_name_error!
  type_option_instead_of_option_error!(:name)
end
type_namespace_instead_of_namespace_error!() click to toggle source
# File lib/avro/builder/types/named_error_handling.rb, line 57
def type_namespace_instead_of_namespace_error!
  type_option_instead_of_option_error!(:namespace)
end
type_option_instead_of_option_error!(name) click to toggle source
# File lib/avro/builder/types/named_error_handling.rb, line 48
def type_option_instead_of_option_error!(name)
  raise AttributeError
    .new("'type_#{name}' must be specified as an option instead of '#{name}'")
end