Class: Metasploit::Model::Base

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations, Translation
Defined in:
lib/metasploit/model/base.rb

Overview

Superclass for all Metasploit::Models. Just adds a default #initialize to make models mimic behavior of ApplicationRecord subclasses.

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Base

Returns a new instance of Base.

Parameters:

  • attributes (Hash{Symbol => String,nil}) (defaults to: {})

10
11
12
13
14
# File 'lib/metasploit/model/base.rb', line 10

def initialize(attributes={})
  attributes.each do |attribute, value|
    public_send("#{attribute}=", value)
  end
end

Instance Method Details

#valid!void

This method returns an undefined value.

Validates the model.

Raises:


20
21
22
23
24
# File 'lib/metasploit/model/base.rb', line 20

def valid!
  unless valid?
    raise Metasploit::Model::Invalid.new(self)
  end
end