Class: Facemock::User
- Inherits:
-
Database::Table
- Object
- Database::Table
- Facemock::User
- Defined in:
- lib/facemock/user.rb
Direct Known Subclasses
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
-
#initialize(options = {}) ⇒ User
constructor
A new instance of User.
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(={}) opts = Hashie::Mash.new() 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