Sha256: c2a133e061b3aa644eb1f8bfd3a1b154019e1a35e20e55ffa2eeadffd62d32c7

Contents?: true

Size: 738 Bytes

Versions: 16

Compression:

Stored size: 738 Bytes

Contents

# Superclass for all Metasploit::Models.  Just adds a default {#initialize} to make models mimic behavior of
# ApplicationRecord subclasses.
class Metasploit::Model::Base
  include ActiveModel::Validations

  # After ActiveModel::Validations so Metasploit::Model::Translation is favored over ActiveModel::Translation
  include Metasploit::Model::Translation

  # @param attributes [Hash{Symbol => String,nil}]
  def initialize(attributes={})
    attributes.each do |attribute, value|
      public_send("#{attribute}=", value)
    end
  end

  # Validates the model.
  #
  # @return [void]
  # @raise [Metasploit::Model::Invalid] if invalid
  def valid!
    unless valid?
      raise Metasploit::Model::Invalid.new(self)
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
metasploit-model-5.0.2 lib/metasploit/model/base.rb
metasploit-model-5.0.1 lib/metasploit/model/base.rb
metasploit-model-5.0.0 lib/metasploit/model/base.rb
metasploit-model-4.0.6 lib/metasploit/model/base.rb
metasploit-model-4.0.5 lib/metasploit/model/base.rb
metasploit-model-4.0.4 lib/metasploit/model/base.rb
metasploit-model-4.0.3 lib/metasploit/model/base.rb
metasploit-model-4.0.2 lib/metasploit/model/base.rb
metasploit-model-4.0.1 lib/metasploit/model/base.rb
metasploit-model-4.0.0 lib/metasploit/model/base.rb
metasploit-model-3.1.4 lib/metasploit/model/base.rb
metasploit-model-3.1.3 lib/metasploit/model/base.rb
metasploit-model-3.1.2 lib/metasploit/model/base.rb
metasploit-model-3.1.1 lib/metasploit/model/base.rb
metasploit-model-3.1.0 lib/metasploit/model/base.rb
metasploit-model-3.0.0 lib/metasploit/model/base.rb