Class: StructuredReader::JSONReader::ObjectReader::ReaderBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/structured_reader.rb

Instance Method Summary collapse

Constructor Details

#initialize(base, reader_set:) ⇒ ReaderBuilder

Returns a new instance of ReaderBuilder.



43
44
45
46
# File 'lib/structured_reader.rb', line 43

def initialize(base, reader_set:)
  @base = base
  @reader_set = reader_set
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(type, name, field_name = name.to_s, *args, **kwargs, &blk) ⇒ Object



48
49
50
51
52
53
54
# File 'lib/structured_reader.rb', line 48

def method_missing(type, name, field_name = name.to_s, *args, **kwargs, &blk)
  if @reader_set.has_reader?(type)
    @base.field name, field_name, @reader_set.reader(type, *args, **kwargs, &blk)
  else
    super
  end
end

Instance Method Details

#respond_to_missing?(type) ⇒ Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/structured_reader.rb', line 56

def respond_to_missing?(type)
  @reader_set.has_reader?(type) || super
end