Module: Metasploit::Model::Translation::ClassMethods
- Defined in:
- lib/metasploit/model/translation.rb
Overview
Adds #lookup_ancestors and #i18n_scope so that Metasploit::Model modules can participate in translation lookups.
Instance Method Summary collapse
-
#i18n_scope ⇒ String
Classes that include a metasploit-model are trying to share code between ActiveRecord and ActiveModel, so the scope should be neither 'activerecord' nor 'activemodel'.
-
#lookup_ancestors ⇒ Array<Module>
When localizing a string, it goes through the lookup returned by this method, which is used in ActiveModel::Name#human, # ActiveModel::Errors#full_messages and ActiveModel::Translation#human_attribute_name.
Instance Method Details
#i18n_scope ⇒ String
Classes that include a metasploit-model are trying to share code between ActiveRecord and ActiveModel, so the scope should be neither 'activerecord' nor 'activemodel'.
27 28 29 |
# File 'lib/metasploit/model/translation.rb', line 27 def i18n_scope 'metasploit.model' end |
#lookup_ancestors ⇒ Array<Module>
When localizing a string, it goes through the lookup returned by this method, which is used in ActiveModel::Name#human, # ActiveModel::Errors#full_messages and ActiveModel::Translation#human_attribute_name.
17 18 19 20 21 |
# File 'lib/metasploit/model/translation.rb', line 17 def lookup_ancestors self.ancestors.select { |ancestor| ancestor.respond_to?(:model_name) } end |