Module: Ronin::DB::Model::HasUniqueName

Included in:
Arch, CertName, HTTPHeaderName, HTTPQueryParamName, Service, SoftwareVendor, URLQueryParamName, URLScheme, UserName
Defined in:
lib/ronin/db/model/has_unique_name.rb

Overview

Adds a unique name property to a model.

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#nameString

The unique name of the model.

Returns:

  • (String)


# File 'lib/ronin/db/model/has_unique_name.rb', line 30

Class Method Details

.included(base) ⇒ Object

Adds the unique name property and Ronin::DB::Model::HasName::ClassMethods to the model.

Parameters:

  • base (Class)

    The model.



46
47
48
49
50
51
52
53
54
55
56
# File 'lib/ronin/db/model/has_unique_name.rb', line 46

def self.included(base)
  base.send :include, Model, HasName::InstanceMethods

  base.send :extend, HasName::ClassMethods, HasUniqueName::ClassMethods

  base.module_eval do
    # The name of the model
    attribute :name, :string
    validates :name, presence: true, uniqueness: true
  end
end