Module: Feiku

Defined in:
lib/feiku.rb,
lib/feiku/unit.rb,
lib/feiku/version.rb,
lib/feiku/generator.rb,
lib/feiku/faker_compat.rb

Overview

Toplevel

Defined Under Namespace

Classes: Error, Generator, MetaProxy, Proxy, Unit

Constant Summary collapse

VERSION =
"0.2.0"

Class Method Summary collapse

Class Method Details

.lookup(module_name, method_name) ⇒ Object

An interface for Faker compatibility



23
24
25
# File 'lib/feiku.rb', line 23

def self.lookup(module_name, method_name)
  @faker_compat_registry.fetch("#{module_name}.#{method_name}")
end

.register(module_name, format:, value:, length: nil, pool_size: 0, faker_compat: nil) ⇒ Object

Primary interface to add fake data definition



15
16
17
18
19
20
# File 'lib/feiku.rb', line 15

def self.register(module_name, format:, value:, length: nil, pool_size: 0, faker_compat: nil) # rubocop:disable Metrics/ParameterLists
  generator = Generator.new(format: format, value: value, length: length, pool_size: pool_size)
  @faker_compat_registry.update(faker_compat => generator) if faker_compat
  remove_const(module_name) if const_defined?(module_name)
  const_set(module_name, generator)
end