Class: Schemaker::Models::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.
14 15 16 |
# File 'lib/schemaker/models/join_model.rb', line 14 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)
36 37 38 39 |
# 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 ⇒ Object
18 19 20 |
# File 'lib/schemaker/models/join_model.rb', line 18 def simple_key clazz_name.to_s.underscore end |
#through_key ⇒ Object
22 23 24 |
# File 'lib/schemaker/models/join_model.rb', line 22 def through_key make_key clazz_name end |