Class: Alchemy::Language
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Alchemy::Language
- Includes:
- Code
- Defined in:
- app/models/alchemy/language.rb
Defined Under Namespace
Modules: Code
Class Method Summary collapse
-
.current ⇒ Object
Current language from current thread or default.
-
.current=(v) ⇒ Object
Store the current language in the current thread.
-
.current_root_page ⇒ Object
The root page of the current language.
-
.default ⇒ Object
(also: get_default)
Default language.
Instance Method Summary collapse
- #label(attrib) ⇒ Object
-
#layout_root_page ⇒ Object
Layout root page.
-
#root_page ⇒ Object
Root page.
Methods included from Code
Class Method Details
.current ⇒ Object
Current language from current thread or default.
65 66 67 |
# File 'app/models/alchemy/language.rb', line 65 def current RequestStore.store[:alchemy_current_language] || default end |
.current=(v) ⇒ Object
Store the current language in the current thread.
60 61 62 |
# File 'app/models/alchemy/language.rb', line 60 def current=(v) RequestStore.store[:alchemy_current_language] = v end |
.current_root_page ⇒ Object
The root page of the current language.
70 71 72 |
# File 'app/models/alchemy/language.rb', line 70 def current_root_page current.pages.language_roots.first end |
.default ⇒ Object Also known as: get_default
Default language
75 76 77 |
# File 'app/models/alchemy/language.rb', line 75 def default find_by(default: true) end |
Instance Method Details
#label(attrib) ⇒ Object
81 82 83 84 85 86 87 |
# File 'app/models/alchemy/language.rb', line 81 def label(attrib) if attrib.to_sym == :code self.code else I18n.t(self.code, default: self.name) end end |
#layout_root_page ⇒ Object
Layout root page
97 98 99 |
# File 'app/models/alchemy/language.rb', line 97 def layout_root_page @layout_root_page ||= Page.layout_root_for(id) end |
#root_page ⇒ Object
Root page
92 93 94 |
# File 'app/models/alchemy/language.rb', line 92 def root_page @root_page ||= pages.language_roots.first end |