Module: Vigilante::ActiveRecordExtensions::ClassMethods

Defined in:
lib/vigilante/active_record_extensions.rb

Instance Method Summary collapse

Instance Method Details

#accessible_extent(user) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/vigilante/active_record_extensions.rb', line 12

def accessible_extent(user)
  extent = user.permits.get_extent_of(self.name.underscore.pluralize, :show)
  if extent.include?('*')
    nil
  else
    # fix: if extent is empty return 0 which would can be used in sql and not match anything
    extent.size == 0 ? '0' : extent.join(',')
  end
end

#authorisations_handled_by_vigilanteObject

run this in the model that is the operator or user or …



23
24
25
26
27
# File 'lib/vigilante/active_record_extensions.rb', line 23

def authorisations_handled_by_vigilante
  module_eval do
    include Vigilante::WatchedOperator
  end
end