Module: AuthAssistant::Helpers::AdminRole

Defined in:
lib/auth_assistant/helpers/admin_role.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



34
35
36
# File 'lib/auth_assistant/helpers/admin_role.rb', line 34

def self.included(base)
  base.helper_method :admin_block, :not_admin_block, :admin_area, :not_admin_area, :admin_or_owner_block, :admin? 
end

Instance Method Details

#admin?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/auth_assistant/helpers/admin_role.rb', line 18

def admin?  
  devise_admin?(on) || cancan_admin?(on)
end

#admin_area(&block) ⇒ Object



22
23
24
25
26
# File 'lib/auth_assistant/helpers/admin_role.rb', line 22

def admin_area(&block)
  admin_block do
    do_admin_area(&block)
  end
end

#admin_block(&block) ⇒ Object



4
5
6
# File 'lib/auth_assistant/helpers/admin_role.rb', line 4

def admin_block(&block)
  with_output_buffer(&block) if admin?
end

#admin_or_owner_block(obj, &block) ⇒ Object



12
13
14
15
16
# File 'lib/auth_assistant/helpers/admin_role.rb', line 12

def admin_or_owner_block(obj, &block)
  if admin? || owner?(obj)
    with_output_buffer(&block)
  end 
end

#not_admin_area(&block) ⇒ Object



28
29
30
31
32
# File 'lib/auth_assistant/helpers/admin_role.rb', line 28

def not_admin_area(&block)
  not_admin_block do
    do_admin_area(&block)
  end
end

#not_admin_block(&block) ⇒ Object



8
9
10
# File 'lib/auth_assistant/helpers/admin_role.rb', line 8

def not_admin_block(&block)
  with_output_buffer(&block) if !admin?
end