Class: Notee::ApplicationRecord

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/notee/application_record.rb

Direct Known Subclasses

Category, Image, Post, User

Instance Method Summary collapse

Instance Method Details

#create_authorityObject



15
16
17
# File 'app/models/notee/application_record.rb', line 15

def create_authority
  Authority.check('create', self)
end

#destroy_authorityObject



23
24
25
# File 'app/models/notee/application_record.rb', line 23

def destroy_authority
  Authority.check('destroy', self)
end

#is_destroy?Boolean

Returns:

  • (Boolean)


27
28
29
30
# File 'app/models/notee/application_record.rb', line 27

def is_destroy?
  return true if self.is_deleted == true
  false
end

#skip_callback_block(model) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/models/notee/application_record.rb', line 32

def skip_callback_block(model)

  return unless block_given?

  model.skip_callback(:create, :before, :create_authority, raise: false)
  model.skip_callback(:update, :before, :update_authority, raise: false)
  model.skip_callback(:update, :before, :destroy_authority, raise: false)

  yield

  model.set_callback(:create, :before, :create_authority, raise: false)
  model.set_callback(:update, :before, :update_authority, raise: false)
  model.set_callback(:update, :before, :destroy_authority, raise: false)
end

#update_authorityObject



19
20
21
# File 'app/models/notee/application_record.rb', line 19

def update_authority
  Authority.check('update', self)
end