Sha256: 683c4262b376ee91c14a150115d837b8f8cfd56ac0a32aac67d2c4670caa4d7b

Contents?: true

Size: 1.11 KB

Versions: 2

Compression:

Stored size: 1.11 KB

Contents

require 'faker'
require 'facemock/database/table'
require 'facemock/permission'
require 'facemock/authorization_code'

module Facemock
  class User < Database::Table
    TABLE_NAME = :users
    COLUMN_NAMES = [:id, :name, :email, :password, :installed, :access_token, :application_id, :created_at]
    CHILDREN = [ Permission, AuthorizationCode ]

    def initialize(options={})
      opts = Hashie::Mash.new(options)
      id = opts.id || opts.identifier
      @id             = (id.to_i > 0) ? id.to_i : ("10000" + Faker::Number.number(10)).to_i
      @name           = opts.name         || create_user_name
      @email          = opts.email        || Faker::Internet.email
      @password       = opts.password     || Faker::Internet.password
      @installed      = opts.installed    || false
      @access_token   = opts.access_token || Faker::Lorem.characters
      app_id = opts.application_id.to_i
      @application_id = (app_id > 0) ? app_id : nil
      @created_at     = opts.created_at
    end

    private

    def create_user_name
      n = Faker::Name.name
      n.include?("'") ? create_user_name : n
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
facemock-0.0.11 lib/facemock/user.rb
facemock-0.0.10 lib/facemock/user.rb