Module: Avro::Builder::DslOptions::ClassMethods

Defined in:
lib/avro/builder/dsl_options.rb

Instance Method Summary collapse

Instance Method Details

#add_option_name(name) ⇒ Object


44
45
46
# File 'lib/avro/builder/dsl_options.rb', line 44

def add_option_name(name)
  dsl_option_names << name
end

#dsl_option(name, dsl_name:) ⇒ Object

Defines a private writer with #dsl_name= to set an attribute stored in the instance variable @#name.


25
26
27
28
29
30
31
32
33
# File 'lib/avro/builder/dsl_options.rb', line 25

def dsl_option(name, dsl_name:)
  add_option_name(name)
  add_attribute_name(dsl_name)
  aliased_writer = "#{dsl_name}="
  define_method(aliased_writer) do |value|
    instance_variable_set("@#{name}", value)
  end
  private(aliased_writer)
end

#dsl_option_namesObject


35
36
37
38
39
40
41
42
# File 'lib/avro/builder/dsl_options.rb', line 35

def dsl_option_names
  @dsl_option_names ||=
    if superclass.respond_to?(:dsl_option_names)
      superclass.dsl_option_names.dup
    else
      Set.new
    end
end