module Metasploit::Model::Translation::ClassMethods

Adds {#lookup_ancestors} and {#i18n_scope} so that {Metasploit::Model} modules can participate in translation lookups.

Public Instance Methods

i18n_scope() click to toggle source

Classes that include a metasploit-model are trying to share code between ActiveRecord and ActiveModel, so the scope should be neither 'activerecord' nor 'activemodel'.

@return [String] `'metasploit.model'`

# File lib/metasploit/model/translation.rb, line 27
def i18n_scope
  'metasploit.model'
end
lookup_ancestors() click to toggle source

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.

@return [Array<Module>] Array of `Class#ancestors` that respond to `module_name`.

# File lib/metasploit/model/translation.rb, line 17
def lookup_ancestors
  self.ancestors.select { |ancestor|
    ancestor.respond_to?(:model_name)
  }
end