Class: Facemock::Database::Application

Inherits:
Table
  • Object
show all
Defined in:
lib/facemock/database/application.rb

Constant Summary collapse

TABLE_NAME =
:applications
COLUMN_NAMES =
[:id, :secret, :created_at]
CHILDREN =
[ User ]

Instance Method Summary collapse

Methods inherited from 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 = {}) ⇒ Application

WANT : DBに登録済みの値と重複しないようにする(id, secret)



12
13
14
15
16
17
# File 'lib/facemock/database/application.rb', line 12

def initialize(options={})
  opts = Hashie::Mash.new(options)
  @id         = ( opts.id.to_i > 0 ) ? opts.id.to_i : (0..9).to_a.shuffle[0..15].join.to_i
  @secret     = opts.secret || rand(36**32).to_s(36)
  @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