Sha256: 64b385af6218c8eaf92240f405e7e2f9dda77981515c2de9151f836509cd301b

Contents?: true

Size: 784 Bytes

Versions: 2

Compression:

Stored size: 784 Bytes

Contents

require "json"
require "ostruct"
require "random_user_generator/core_extensions/open_struct/hash_assignment"

require "faraday"
require 'faraday_middleware'

require "random_user_generator/configuration"
require "random_user_generator/client"

require "random_user_generator/version"

module RandomUserGenerator
  extend Configuration

  def self.generate(params = {})
    results = client.request(params)
    users   = JSON.parse(results.to_json, object_class: OpenStruct)

    params[:results] ? users : users.first
  end

  def self.generate_female(params = {})
    params.merge!(gender: 'female')
    generate(params)
  end

  def self.generate_male(params = {})
    params.merge!(gender: 'male')
    generate(params)
  end

  def self.client
    @client ||= Client.new
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
random_user_generator-0.2.1 lib/random_user_generator.rb
random_user_generator-0.2.0 lib/random_user_generator.rb