Class: Ibrain::Base

Inherits:
ApplicationRecord show all
Includes:
ActionView::Helpers::DateHelper
Defined in:
app/models/ibrain/base.rb

Direct Known Subclasses

LegacyUser, Role, RoleUser

Constant Summary collapse

IGNORE_ATTRIBUTES =
%w(id created_at updated_at)

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.adjust_date_for_cdt(datetime) ⇒ Object



51
52
53
# File 'app/models/ibrain/base.rb', line 51

def adjust_date_for_cdt(datetime)
  datetime.in_time_zone('UTC')
end

.display_includesObject

Provides a scope that should be included any time data are fetched with the intention of displaying to the user.

Allows individual stores to include any active record scopes or joins when data are displayed.



43
44
45
# File 'app/models/ibrain/base.rb', line 43

def display_includes
  where(nil)
end

.paginate(args) ⇒ Object



47
48
49
# File 'app/models/ibrain/base.rb', line 47

def paginate(args)
  limit(args[:limit]).offset(args[:offset])
end

.permitted_attributesObject



55
56
57
# File 'app/models/ibrain/base.rb', line 55

def permitted_attributes
  column_names.reject { |k| IGNORE_ATTRIBUTES.include?(k) }
end

Instance Method Details

#created_in_wordObject



33
34
35
# File 'app/models/ibrain/base.rb', line 33

def created_in_word
  time_ago_in_words(created_at)
end

#cryptorObject



29
30
31
# File 'app/models/ibrain/base.rb', line 29

def cryptor
  ::Ibrain::Encryptor.new
end

#string_idObject



10
11
12
# File 'app/models/ibrain/base.rb', line 10

def string_id
  try(:id).try(:to_s)
end