Module: Faker::Config

Defined in:
lib/faker.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.default_locale=(value) ⇒ Object (writeonly)

Sets the attribute default_locale

Parameters:

  • value

    the value to set the attribute default_locale to.



17
18
19
# File 'lib/faker.rb', line 17

def default_locale=(value)
  @default_locale = value
end

Class Method Details

.localeObject



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

def locale
  # Because I18n.locale defaults to :en, if we don't have :en in our available_locales, errors will happen
  Thread.current[:faker_config_locale] || @default_locale || (I18n.available_locales.include?(I18n.locale) ? I18n.locale : I18n.available_locales.first)
end

.locale=(new_locale) ⇒ Object



19
20
21
# File 'lib/faker.rb', line 19

def locale=(new_locale)
  Thread.current[:faker_config_locale] = new_locale
end

.own_localeObject



28
29
30
# File 'lib/faker.rb', line 28

def own_locale
  Thread.current[:faker_config_locale]
end

.randomObject



36
37
38
# File 'lib/faker.rb', line 36

def random
  Thread.current[:faker_config_random] || Random
end

.random=(new_random) ⇒ Object



32
33
34
# File 'lib/faker.rb', line 32

def random=(new_random)
  Thread.current[:faker_config_random] = new_random
end