Class: Space
- Inherits:
-
Object
- Object
- Space
- 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
- .available_themes ⇒ Object
- .current ⇒ Object
- .current=(space) ⇒ Object
- .current? ⇒ Boolean
- .default?(name) ⇒ Boolean
- .permissions ⇒ Object
Instance Method Summary collapse
- #custom_roles_as_string ⇒ Object
- #custom_roles_as_string=(str) ⇒ Object
-
#default? ⇒ Boolean
end.
- #menu_as_string ⇒ Object
- #menu_as_string=(str) ⇒ Object
- #permissions ⇒ Object
- #slug ⇒ Object
Class Method Details
.available_themes ⇒ Object
134 135 136 |
# File 'lib/rad/models/space.rb', line 134 def self.available_themes config.available_themes(['default']) end |
.current ⇒ Object
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
43 44 45 |
# File 'lib/rad/models/space.rb', line 43 def self.current? !!Thread.current['current_space'] end |
.default?(name) ⇒ Boolean
26 |
# File 'lib/rad/models/space.rb', line 26 def self.default? name; name == 'default' end |
.permissions ⇒ Object
79 80 81 82 83 84 85 |
# File 'lib/rad/models/space.rb', line 79 def self. 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_string ⇒ Object
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
25 |
# File 'lib/rad/models/space.rb', line 25 def default?; name == 'default' end |
#menu_as_string ⇒ Object
94 95 96 |
# File 'lib/rad/models/space.rb', line 94 def .to_a.collect{|name, url| "#{name}:#{url}"}.join("\n") end |
#menu_as_string=(str) ⇒ Object
98 99 100 101 102 103 104 105 |
# File 'lib/rad/models/space.rb', line 98 def (str) self. = [] lines = str.split("\n") lines.each do |line| name, url = line.split(':').collect(&:strip) << [name, url] unless name.blank? or url.blank? end end |
#permissions ⇒ Object
74 75 76 |
# File 'lib/rad/models/space.rb', line 74 def self.class. end |
#slug ⇒ Object
145 |
# File 'lib/rad/models/space.rb', line 145 def slug; name end |