Module: Vigilante::ActiveRecordExtensions::ClassMethods

Defined in:
lib/vigilante/active_record_extensions.rb

Instance Method Summary collapse

Instance Method Details

#authorisations_handled_by_vigilanteObject

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



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

def authorisations_handled_by_vigilante
  module_eval do
    include Vigilante::WatchedOperator
  end
end

#operator_extent(operator) ⇒ Object



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

def operator_extent(operator)
  extent = operator.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