Class: Schemaker::JoinModel
- Defined in:
- lib/schemaker/models/join_model.rb
Instance Attribute Summary
Attributes inherited from BaseModel
Instance Method Summary collapse
-
#configure ⇒ Object
Example: UsersRoles belongs_to :user, :class_name => ‘UserAccount’ (subject) belongs_to :role, :class_name => ‘Role’ (object).
-
#initialize(models, clazz) ⇒ JoinModel
constructor
A new instance of JoinModel.
- #simple_key ⇒ Object
- #through_key ⇒ Object
Methods inherited from BaseModel
Constructor Details
#initialize(models, clazz) ⇒ JoinModel
Returns a new instance of JoinModel.
13 14 15 |
# File 'lib/schemaker/models/join_model.rb', line 13 def initialize models, clazz super end |
Instance Method Details
#configure ⇒ Object
Note:
Do not call super here!
Example:
UsersRoles
belongs_to :user, :class_name => 'UserAccount' (subject)
belongs_to :role, :class_name => 'Role' (object)
35 36 37 38 |
# File 'lib/schemaker/models/join_model.rb', line 35 def configure create_belongs_to :subject, class_name_option(:subject) create_belongs_to :object, class_name_option(:object) end |
#simple_key ⇒ Object
17 18 19 |
# File 'lib/schemaker/models/join_model.rb', line 17 def simple_key clazz_name.to_s.underscore end |
#through_key ⇒ Object
21 22 23 |
# File 'lib/schemaker/models/join_model.rb', line 21 def through_key make_key clazz_name end |