Module: Ronin::Model::HasAuthors

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

Overview

Adds an authors relationship between a model and the Author model.

Defined Under Namespace

Modules: ClassMethods, InstanceMethods

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object

Adds the authors relationship and ClassMethods to the model.

Parameters:

  • base (Class)

    The model.


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

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

  base.module_eval do
    # The authors associated with the model.
    has 0..n, :authors, Ronin::Author, :through => DataMapper::Resource

    Ronin::Author.has 0..n, self.relationship_name,
                            :through => DataMapper::Resource,
                            :model => self
  end
end