Class: GuestUser

Inherits:
User
  • Object
show all
Defined in:
app/models/guest_user.rb

Instance Method Summary collapse

Methods inherited from User

#able_to_edit_or_publish_content?, #able_to_modify?, #able_to_publish?, current, current=, #disable, #disable!, #enable, #enable!, #expired?, #expires_at_formatted, #full_name, #full_name_with_login, guest, #guest?, #modifiable_sections, #permissions, #viewable_sections

Methods included from Cms::Authentication::Model

included

Constructor Details

#initialize(attributes = {}) ⇒ GuestUser

Returns a new instance of GuestUser.



3
4
5
6
# File 'app/models/guest_user.rb', line 3

def initialize(attributes={})
  super({:login => "guest", :first_name => "Anonymous", :last_name => "User"}.merge(attributes))
  @guest = true
end

Instance Method Details

#able_to?(*name) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
# File 'app/models/guest_user.rb', line 8

def able_to?(*name)
  group && group.permissions.count(:conditions => ["name in (?)", name.map(&:to_s)]) > 0
end

#able_to_edit?(section) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'app/models/guest_user.rb', line 16

def able_to_edit?(section)
  false
end

#able_to_view?(page) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'app/models/guest_user.rb', line 12

def able_to_view?(page)
  group && !!(group.sections.include?(page.section))
end

#groupObject



20
21
22
# File 'app/models/guest_user.rb', line 20

def group
  @group ||= Group.find_by_code("guest")
end

#groupsObject



24
25
26
# File 'app/models/guest_user.rb', line 24

def groups
  [group]
end

#save(perform_validation = true) ⇒ Object



35
36
37
# File 'app/models/guest_user.rb', line 35

def save(perform_validation=true)
  false
end

#update_attribute(name, value) ⇒ Object

You shouldn’t be able to save a guest user



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

def update_attribute(name, value)
  false
end

#update_attributes(attrs = {}) ⇒ Object



32
33
34
# File 'app/models/guest_user.rb', line 32

def update_attributes(attrs={})
  false
end