Module: Ronin::Model::HasLicense

Included in:
Repository
Defined in:
lib/ronin/model/has_license.rb

Overview

Adds a license relationship between a model and the License model.

Defined Under Namespace

Modules: ClassMethods, InstanceMethods

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object

Adds the license relationship and ClassMethods to the model.

Parameters:

  • base (Class)

    The model.



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

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

  base.module_eval do
    # The license
    belongs_to :license, Ronin::License, :required => false

    Ronin::License.has 0..n, self.relationship_name, :model => self
  end
end