Module: Avro::Builder::Metadata

Included in:
Field, Types::Type
Defined in:
lib/avro/builder/metadata.rb

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(id, *args, &block) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/avro/builder/metadata.rb', line 39

def method_missing(id, *args, &block)
  if (id)
    (id, args)
  else
    super
  end
end

Class Method Details

.attribute?(name) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/avro/builder/metadata.rb', line 26

def attribute?(name)
  attribute_names.include?(name.to_sym)
end

.register(*attrs) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/avro/builder/metadata.rb', line 9

def register(*attrs)
  attrs = attrs.flatten.map(&:to_sym) - attribute_names.to_a

  reserved = attrs & Avro::Builder::DslAttributes::ATTRIBUTE_NAMES
  if reserved.any?
    raise ArgumentError.new(
      "Extra metadata attribute(s) use reserved name(s): #{reserved.join(', ')}"
    )
  end

  attribute_names.merge(attrs)
end

.reset! ⇒ Object



22
23
24
# File 'lib/avro/builder/metadata.rb', line 22

def reset!
  attribute_names.clear
end

Instance Method Details

#respond_to_missing?(id, include_all) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/avro/builder/metadata.rb', line 35

def respond_to_missing?(id, include_all)
  (id) || super
end