Module: Legion::Data::Model::Identity::ModelHelpers

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(model) ⇒ Object



10
11
12
# File 'lib/legion/data/models/identity/model_helpers.rb', line 10

def self.included(model)
  model.extend(ClassMethods)
end

.table_available?(table_name) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
17
18
# File 'lib/legion/data/models/identity/model_helpers.rb', line 14

def self.table_available?(table_name)
  Legion::Data::Connection.sequel&.table_exists?(table_name)
rescue StandardError
  false
end

Instance Method Details

#before_createObject



78
79
80
81
# File 'lib/legion/data/models/identity/model_helpers.rb', line 78

def before_create
  self[:uuid] ||= SecureRandom.uuid if self.class.columns.include?(:uuid)
  super
end