Module: Faker::Config
- Defined in:
- lib/faker.rb
Class Attribute Summary collapse
-
.default_locale ⇒ Object
writeonly
Sets the attribute default_locale.
Class Method Summary collapse
- .lazy_loading=(value) ⇒ Object
- .lazy_loading? ⇒ Boolean
- .locale ⇒ Object
- .locale=(new_locale) ⇒ Object
- .own_locale ⇒ Object
- .random ⇒ Object
- .random=(new_random) ⇒ Object
Class Attribute Details
.default_locale=(value) ⇒ Object (writeonly)
Sets the attribute default_locale
19 20 21 |
# File 'lib/faker.rb', line 19 def default_locale=(value) @default_locale = value end |
Class Method Details
.lazy_loading=(value) ⇒ Object
50 51 52 |
# File 'lib/faker.rb', line 50 def lazy_loading=(value) Thread.current[:faker_lazy_loading] = value end |
.lazy_loading? ⇒ Boolean
42 43 44 45 46 47 48 |
# File 'lib/faker.rb', line 42 def lazy_loading? if ENV.key?('FAKER_LAZY_LOAD') && !ENV['FAKER_LAZY_LOAD'].nil? %w[true TRUE 1].include?(ENV.fetch('FAKER_LAZY_LOAD', nil)) else Thread.current[:faker_lazy_loading] == true end end |
.locale ⇒ Object
25 26 27 28 |
# File 'lib/faker.rb', line 25 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
21 22 23 |
# File 'lib/faker.rb', line 21 def locale=(new_locale) Thread.current[:faker_config_locale] = new_locale end |
.own_locale ⇒ Object
30 31 32 |
# File 'lib/faker.rb', line 30 def own_locale Thread.current[:faker_config_locale] end |
.random ⇒ Object
38 39 40 |
# File 'lib/faker.rb', line 38 def random Thread.current[:faker_config_random] || Random end |
.random=(new_random) ⇒ Object
34 35 36 |
# File 'lib/faker.rb', line 34 def random=(new_random) Thread.current[:faker_config_random] = new_random end |