Method: Faker::Base.fetch

Defined in:
lib/faker.rb

.fetch(key) ⇒ Object

Helper for the common approach of grabbing a translation with an array of values and selecting one of them.



90
91
92
93
94
95
96
97
98
# File 'lib/faker.rb', line 90

def fetch(key)
  fetched = translate("faker.#{key}")
  fetched = fetched.sample if fetched.respond_to?(:sample)
  if fetched.match(/^\//) and fetched.match(/\/$/) # A regex
    regexify(fetched)
  else
    fetched
  end
end