Class: PositionalGenerator::Builder::Oneof::OneofSelector

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

Instance Method Summary collapse

Constructor Details

#initialize(builder) ⇒ OneofSelector

Returns a new instance of OneofSelector.



382
383
384
385
# File 'lib/helpers/positional_generator.rb', line 382

def initialize(builder)
  @subgens = []
  @builder = Builder.new(builder.as_type)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, **kwargs, &block) ⇒ Object



387
388
389
# File 'lib/helpers/positional_generator.rb', line 387

def method_missing(meth, *args, **kwargs, &block)
  @subgens << [meth, args, kwargs, block]
end

Instance Method Details

#generateObject



400
401
402
# File 'lib/helpers/positional_generator.rb', line 400

def generate(...)
  @builder.build
end

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


391
392
393
# File 'lib/helpers/positional_generator.rb', line 391

def respond_to_missing?(method_name, include_private = false)
  @builder.respond_to?(method_name, include_private)
end

#sampleObject



395
396
397
398
# File 'lib/helpers/positional_generator.rb', line 395

def sample
  (meth, args, kwargs, block) = Faker::Base.sample(@subgens)
  @builder.send(meth, *args, **kwargs, &block)
end