Sha256: 318d5e733d9b78fb10730431ab12a33674c271e9ecd319eea35d2d2ab7973aaf

Contents?: true

Size: 778 Bytes

Versions: 8

Compression:

Stored size: 778 Bytes

Contents

require 'metasploit/model/translation'

# Superclass for all Metasploit::Models.  Just adds a default {#initialize} to make models mimic behavior of
# ActiveRecord::Base 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

8 entries across 8 versions & 1 rubygems

Version Path
metasploit-model-0.27.3 lib/metasploit/model/base.rb
metasploit-model-0.27.3-java lib/metasploit/model/base.rb
metasploit-model-0.27.2 lib/metasploit/model/base.rb
metasploit-model-0.27.2-java lib/metasploit/model/base.rb
metasploit-model-0.27.1 lib/metasploit/model/base.rb
metasploit-model-0.27.1-java lib/metasploit/model/base.rb
metasploit-model-0.27.0 lib/metasploit/model/base.rb
metasploit-model-0.27.0-java lib/metasploit/model/base.rb