Module: Ronin::Model::HasUniqueName

Included in:
Arch, Campaign, License, Organization, Service, URLQueryParamName, URLScheme, UserName, Vendor
Defined in:
lib/ronin/model/has_unique_name.rb

Overview

Adds a unique name property to a model.

Defined Under Namespace

Modules: ClassMethods, InstanceMethods

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object

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

Parameters:

  • base (Class)

    The model.



37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/ronin/model/has_unique_name.rb', line 37

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

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

  base.module_eval do
    # The name of the model
    property :name, String, :required => true, :unique => true
  end
end