Sha256: 8ecd9e03947dd883a1e7e5980c3bccd50040a1e95b788571076ad8810b2c2f7a
Contents?: true
Size: 1.04 KB
Versions: 2
Compression:
Stored size: 1.04 KB
Contents
# # @author Kristian Mandrup # # Model configuration of the Object model (fx Role) # # Knows how to configure the relationship fro the Object model to the subject model via the Join model # module Schemaker class ObjectModel < BaseModel # @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! def initialize models, clazz super end # Configures has_many through relationship via Join model for the object model (fx Role) # # Example: # Role (object) # has_many :accounts, :class_name => 'RefManyAccount', :through => :accounts_roles (subject) # has_many :user_roles, :class_name => 'UserRole' (join) def configure super create_has_many_through :subject end # @note important to use super to avoid recursive stack overflow! def through_options options = {} options.merge super(:subject) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
schemaker-0.1.1 | lib/schemaker/models/object_model.rb |
schemaker-0.1.0 | lib/schemaker/models/object_model.rb |