Module: Mongoid::Translate
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/mongoid/translate.rb,
lib/mongoid_translate.rb,
lib/mongoid/translate/slug.rb,
lib/mongoid/translate/version.rb,
lib/mongoid/translate/resources.rb
Defined Under Namespace
Modules: ClassMethods, Resources, Slug
Constant Summary collapse
- VERSION =
"1.0.2"
Instance Method Summary collapse
-
#languages ⇒ Array
Return list of existing languages.
-
#main_translation ⇒ Document
Return main translation object.
- #method_missing(method, *args, &block) ⇒ Object
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/mongoid/translate.rb', line 40 def method_missing(method, *args, &block) if self.languages.include?(method) translations.where(language: method).one else super(method, *args, &block) end end |
Instance Method Details
#languages ⇒ Array
Return list of existing languages
28 29 30 |
# File 'lib/mongoid/translate.rb', line 28 def languages translations.map(&:language) end |
#main_translation ⇒ Document
Return main translation object
36 37 38 |
# File 'lib/mongoid/translate.rb', line 36 def main_translation translations.where(language: main_language).one end |