Class: Space

Inherits:
Object
  • Object
show all
Includes:
MongoMapper::Document, Paperclip
Defined in:
lib/rad/models/space.rb

Constant Summary collapse

SPECIAL_PERMISSIONS =
{
  'global_administration' => ['admin'],
  'account_administration' => ['admin'],
  'view' => ['owner', 'manager']
}
AVAILABLE_LANGUAGES =

Language

%w{en ru}
@@permissions =
nil

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.available_themesObject



134
135
136
# File 'lib/rad/models/space.rb', line 134

def self.available_themes
  config.available_themes(['default'])
end

.currentObject



39
40
41
# File 'lib/rad/models/space.rb', line 39

def self.current
  Thread.current['current_space'].must_be.defined
end

.current=(space) ⇒ Object



35
36
37
# File 'lib/rad/models/space.rb', line 35

def self.current= space
  Thread.current['current_space'] = space
end

.current?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/rad/models/space.rb', line 43

def self.current?
  !!Thread.current['current_space']
end

.default?(name) ⇒ Boolean

Returns:

  • (Boolean)


26
# File 'lib/rad/models/space.rb', line 26

def self.default? name; name == 'default' end

.permissionsObject



79
80
81
82
83
84
85
# File 'lib/rad/models/space.rb', line 79

def self.permissions
  unless @@permissions
   @@permissions = YAML.load_file("#{File.dirname __FILE__}/default_permissions.yml")
   @@permissions.merge!(SPECIAL_PERMISSIONS)
  end
  @@permissions
end

Instance Method Details

#custom_roles_as_stringObject



61
62
63
# File 'lib/rad/models/space.rb', line 61

def custom_roles_as_string
  custom_roles.join("\n")
end

#custom_roles_as_string=(str) ⇒ Object



64
65
66
# File 'lib/rad/models/space.rb', line 64

def custom_roles_as_string= str
  self.custom_roles = str.strip.split("\n")
end

#default?Boolean

end

Returns:

  • (Boolean)


25
# File 'lib/rad/models/space.rb', line 25

def default?; name == 'default' end


94
95
96
# File 'lib/rad/models/space.rb', line 94

def menu_as_string
  menu.to_a.collect{|name, url| "#{name}:#{url}"}.join("\n") 
end


98
99
100
101
102
103
104
105
# File 'lib/rad/models/space.rb', line 98

def menu_as_string=(str)
  self.menu = []
  lines = str.split("\n") 
  lines.each do |line|
    name, url = line.split(':').collect(&:strip)
    menu << [name, url] unless name.blank? or url.blank?
  end
end

#permissionsObject



74
75
76
# File 'lib/rad/models/space.rb', line 74

def permissions
  self.class.permissions
end

#slugObject



145
# File 'lib/rad/models/space.rb', line 145

def slug; name end