Class: Fakerize::Configuration

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Configuration

config = {

email: ->() { Faker::Internet.email },
first_name: ->() { Faker::Name.first_name },
last_name: ->() { Faker::Name.last_name }

}

Parameters:

  • Hash


12
13
14
15
16
17
18
19
20
21
# File 'lib/fakerize/configuration.rb', line 12

def initialize(config)
  @config = config
  @attributes = config.keys

  attributes.each do |attribute|
    define_singleton_method attribute do
      config[attribute]
    end
  end
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



2
3
4
# File 'lib/fakerize/configuration.rb', line 2

def attributes
  @attributes
end

#configObject (readonly)

Returns the value of attribute config.



2
3
4
# File 'lib/fakerize/configuration.rb', line 2

def config
  @config
end