class Schemaker::Models::JoinModel

Public Class Methods

new(models, clazz) click to toggle source

@param [Schema::Models] each model needs to have access to the collection of models it may need to create relations with @param [Class] reference to the Class it aims to configure!

Calls superclass method Schemaker::Models::BaseModel::new
# File lib/schemaker/models/join_model.rb, line 14
def initialize models, clazz
  super
end

Public Instance Methods

configure() click to toggle source

Example:

UsersRoles
  belongs_to :user, :class_name => 'UserAccount' (subject)
  belongs_to :role, :class_name => 'Role' (object)

@note Do not call super here!

# File lib/schemaker/models/join_model.rb, line 36
def configure
  create_belongs_to :subject, class_name_option(:subject)
  create_belongs_to :object, class_name_option(:object)
end
simple_key() click to toggle source
# File lib/schemaker/models/join_model.rb, line 18
def simple_key
  clazz_name.to_s.underscore
end
through_key() click to toggle source
# File lib/schemaker/models/join_model.rb, line 22
def through_key
  make_key clazz_name
end