Class: Cms::GuestUser

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

Instance Method Summary collapse

Methods inherited from User

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

Constructor Details

#initialize(attributes = {}) ⇒ GuestUser

Returns a new instance of GuestUser



10
11
12
13
# File 'app/models/cms/guest_user.rb', line 10

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

Instance Method Details

#able_to?(*name) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#able_to_edit?(section) ⇒ Boolean

Returns:

  • (Boolean)


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

def able_to_edit?(section)
  false
end

#cms_access?Boolean

Guests never get access to the CMS. Overridden from user so that able_to_view? will work correctly.

Returns:

  • (Boolean)


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

def cms_access?
  false
end

#groupObject



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

def group
  @group ||= Cms::Group.guest
end

#groupsObject



39
40
41
# File 'app/models/cms/guest_user.rb', line 39

def groups
  [group]
end

#save(perform_validation = true) ⇒ Object



52
53
54
# File 'app/models/cms/guest_user.rb', line 52

def save(perform_validation=true)
  false
end

#update_attribute(name, value) ⇒ Object

You shouldn't be able to save a guest user



44
45
46
# File 'app/models/cms/guest_user.rb', line 44

def update_attribute(name, value)
  false
end

#update_attributes(attrs = {}) ⇒ Object



48
49
50
# File 'app/models/cms/guest_user.rb', line 48

def update_attributes(attrs={})
  false
end

#viewable_sectionsObject

Return a list of the sections associated with this user that can be viewed. Overridden from user so that able_to_view? will work correctly.



27
28
29
# File 'app/models/cms/guest_user.rb', line 27

def viewable_sections
  group.sections
end