Class: Facemock::User

Inherits:
Database::Table show all
Defined in:
lib/facemock/user.rb

Direct Known Subclasses

FbGraph::Application::User

Constant Summary collapse

TABLE_NAME =
:users
COLUMN_NAMES =
[:id, :name, :email, :password, :installed, :access_token, :application_id, :created_at]
CHILDREN =
[ Permission, AuthorizationCode ]

Instance Method Summary collapse

Methods inherited from Database::Table

all, children, #column_names, column_names, column_type, create!, #destroy, #fetch, first, last, #method_missing, method_missing, #persisted?, #save!, table_info, #table_name, table_name, #update_attributes!, where

Constructor Details

#initialize(options = {}) ⇒ User

Returns a new instance of User.



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/facemock/user.rb', line 11

def initialize(options={})
  opts = Hashie::Mash.new(options)
  id = opts.id || opts.identifier
  @id             = (id.to_i > 0) ? id.to_i : ("10000" + (0..9).to_a.shuffle[0..10].join).to_i
  @name           = opts.name         || rand(36**10).to_s(36)
  @email          = opts.email        || name.gsub(" ", "_") + "@example.com"
  @password       = opts.password     || rand(36**10).to_s(36)
  @installed      = opts.installed    || false
  @access_token   = opts.access_token || rand(36**255).to_s(36)
  app_id = opts.application_id.to_i
  @application_id = (app_id > 0) ? app_id : nil
  @created_at     = opts.created_at
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Facemock::Database::Table