module Faker::ModuleUtils
Public Instance Methods
const_missing(const_name)
click to toggle source
Calls superclass method
# File lib/ffakerer/utils/module_utils.rb, line 9 def const_missing(const_name) if const_name =~ /[a-z]/ # Not a constant, probably a class/module name. super const_name else mod_name = ancestors.first.to_s.split("::").last data_path = "#{Faker::BASE_LIB_PATH}/ffakerer/data/#{underscore(mod_name)}/#{underscore(const_name.to_s)}" data = k File.read(data_path).split("\n") const_set const_name, data data end end
k(arg)
click to toggle source
# File lib/ffakerer/utils/module_utils.rb, line 5 def k(arg) Faker::ArrayUtils.const_array(arg) end
underscore(string)
click to toggle source
# File lib/ffakerer/utils/module_utils.rb, line 21 def underscore(string) string.gsub(/::/, '/'). gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2'). tr("-", "_"). downcase end