Module: MetasploitDataModels::SerializedPrefs

Included in:
Mdm::Macro, Mdm::User
Defined in:
lib/metasploit_data_models/serialized_prefs.rb

Instance Method Summary collapse

Instance Method Details

#serialized_prefs_attr_accessor(*args) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/metasploit_data_models/serialized_prefs.rb', line 3

def serialized_prefs_attr_accessor(*args)
  args.each do |method_name|

    method_declarations = <<-RUBY
      def #{method_name}
        return if not self.prefs
        self.prefs[:#{method_name}]
      end

      def #{method_name}=(value)
        temp = self.prefs || {}
        temp[:#{method_name}] = value
        self.prefs = temp
      end
    RUBY

    class_eval method_declarations, __FILE__, __LINE__
  end
end