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.



37
38
39
40
# File 'lib/structured_reader.rb', line 37

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



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

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)


50
51
52
# File 'lib/structured_reader.rb', line 50

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