Class: Faker::Json
Constant Summary
Constants inherited from Base
Base::LLetters, Base::Letters, Base::NOT_GIVEN, Base::Numbers, Base::ULetters
Class Method Summary collapse
-
.add_depth_to_json(legacy_json = NOT_GIVEN, legacy_width = NOT_GIVEN, legacy_options = NOT_GIVEN, json: shallow_json, width: 3, options: { key: 'Name.first_name', value: 'Name.first_name' }) ⇒ Object
rubocop:disable Metrics/ParameterLists.
- .shallow_json(legacy_width = NOT_GIVEN, legacy_options = NOT_GIVEN, width: 3, options: { key: 'Name.first_name', value: 'Name.first_name' }) ⇒ Object
Methods inherited from Base
bothify, disable_enforce_available_locales, fetch, fetch_all, flexible, letterify, method_missing, numerify, parse, rand, rand_in_range, regexify, resolve, respond_to_missing?, sample, shuffle, translate, unique, with_locale
Class Method Details
.add_depth_to_json(legacy_json = NOT_GIVEN, legacy_width = NOT_GIVEN, legacy_options = NOT_GIVEN, json: shallow_json, width: 3, options: { key: 'Name.first_name', value: 'Name.first_name' }) ⇒ Object
rubocop:disable Metrics/ParameterLists
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/faker/default/json.rb', line 20 def add_depth_to_json(legacy_json = NOT_GIVEN, legacy_width = NOT_GIVEN, = NOT_GIVEN, json: shallow_json, width: 3, options: { key: 'Name.first_name', value: 'Name.first_name' }) # rubocop:enable Metrics/ParameterLists warn_for_deprecated_arguments do |keywords| keywords << :json if legacy_json != NOT_GIVEN end warn_for_deprecated_arguments do |keywords| keywords << :width if legacy_width != NOT_GIVEN end warn_for_deprecated_arguments do |keywords| keywords << :options if != NOT_GIVEN end [:key] = 'Faker::' + [:key] [:value] = 'Faker::' + [:value] hash = JSON.parse(json) hash.each do |key, _| add_hash_to_bottom(hash, [key], width, ) end JSON.generate(hash) end |
.shallow_json(legacy_width = NOT_GIVEN, legacy_options = NOT_GIVEN, width: 3, options: { key: 'Name.first_name', value: 'Name.first_name' }) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/faker/default/json.rb', line 6 def shallow_json(legacy_width = NOT_GIVEN, = NOT_GIVEN, width: 3, options: { key: 'Name.first_name', value: 'Name.first_name' }) warn_for_deprecated_arguments do |keywords| keywords << :width if legacy_width != NOT_GIVEN keywords << :options if != NOT_GIVEN end [:key] = 'Faker::' + [:key] [:value] = 'Faker::' + [:value] hash = build_shallow_hash(width, ) JSON.generate(hash) end |