Module: Ronin::DB::Model::HasName

Included in:
OS, Organization, OrganizationDepartment, Software
Defined in:
lib/ronin/db/model/has_name.rb

Overview

Adds a name property to a model.

Defined Under Namespace

Modules: ClassMethods, InstanceMethods

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#nameString

The name attribute of the model.

Returns:

  • (String)


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

Class Method Details

.included(base) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Adds the name property and ClassMethods to the model.

Parameters:

  • base (Class)

    The model.



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

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

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