Class: Site
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Site
- Defined in:
- lib/models/site.rb
Constant Summary collapse
- PREFERENCE_PATHS =
[ 'system:theme_folder_path', 'system:captcha_path', 'template:tmpl_file_basepath', 'member:avatar_path', 'member:photo_path', 'member:sig_img_path', 'member:prv_msg_upload_path' ]
Instance Method Summary collapse
- #after_initialize ⇒ Object
- #name ⇒ Object
- #preferences ⇒ Object
- #root_path ⇒ Object
- #root_path=(other) ⇒ Object
- #slug ⇒ Object
- #update_preferences ⇒ Object
Instance Method Details
#after_initialize ⇒ Object
20 21 22 |
# File 'lib/models/site.rb', line 20 def after_initialize @preferences = Hash.new end |
#name ⇒ Object
24 25 26 |
# File 'lib/models/site.rb', line 24 def name self.site_label end |
#preferences ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/models/site.rb', line 32 def preferences if @preferences.empty? preference_map.each do |key, method_base| @preferences[key] = ExpressionEngine::Preference.new(self.send(method_base.to_sym)) end end @preferences end |
#root_path ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/models/site.rb', line 55 def root_path common_elements = nil PREFERENCE_PATHS.each do |preference| group, setting = preference.split(':') path = self.preferences[group.to_sym][setting.to_sym].split('/') unless path.empty? common_elements = path if common_elements.nil? common_elements = common_elements & path end end common_elements.join('/') end |
#root_path=(other) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/models/site.rb', line 47 def root_path=(other) pattern = Regexp.quote(self.root_path) PREFERENCE_PATHS.each do |preference| group, setting = preference.split(':') self.preferences[group.to_sym][setting.to_sym].gsub!(/^#{pattern}/, other) end end |
#slug ⇒ Object
28 29 30 |
# File 'lib/models/site.rb', line 28 def slug self.site_name end |
#update_preferences ⇒ Object
41 42 43 44 45 |
# File 'lib/models/site.rb', line 41 def update_preferences preference_map.each do |key, method_base| self.send("#{method_base}=".to_sym, @preferences[key].to_s) end end |