Class: Schemaker::Models::BaseModel
- Inherits:
-
Object
- Object
- Schemaker::Models::BaseModel
- Defined in:
- lib/schemaker/models/base_model.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#logs ⇒ Object
readonly
can be used to later check which relationships were set up.
-
#models ⇒ Object
Returns the value of attribute models.
-
#my_class ⇒ Object
Returns the value of attribute my_class.
Class Method Summary collapse
Instance Method Summary collapse
-
#clazz_name ⇒ String
(also: #my_class_name)
The class name of the Class to be configured.
-
#configure ⇒ Object
The models :subject and :object must both be configured with a has_many relationship to the join model which the has_many :through references.
-
#initialize(models, my_class) ⇒ BaseModel
constructor
A new instance of BaseModel.
Constructor Details
#initialize(models, my_class) ⇒ BaseModel
Returns a new instance of BaseModel.
16 17 18 19 20 21 22 23 |
# File 'lib/schemaker/models/base_model.rb', line 16 def initialize models, my_class raise ArgumentError, "The first argument must be a Schema::Models instance, was #{models}" if !models.is_a?(Schemaker::Models) raise ArgumentError, "The second argument must be the Class that is to be configured, was #{my_class}" if !my_class.is_a?(Class) @models = models @my_class = my_class @logs = [] end |
Instance Attribute Details
#logs ⇒ Object (readonly)
can be used to later check which relationships were set up
12 13 14 |
# File 'lib/schemaker/models/base_model.rb', line 12 def logs @logs end |
#models ⇒ Object
Returns the value of attribute models.
11 12 13 |
# File 'lib/schemaker/models/base_model.rb', line 11 def models @models end |
#my_class ⇒ Object
Returns the value of attribute my_class.
11 12 13 |
# File 'lib/schemaker/models/base_model.rb', line 11 def my_class @my_class end |
Class Method Details
.model_types ⇒ Object
38 39 40 |
# File 'lib/schemaker/models/base_model.rb', line 38 def self.model_types [:object, :subject, :join] end |
Instance Method Details
#clazz_name ⇒ String Also known as: my_class_name
The class name of the Class to be configured
33 34 35 |
# File 'lib/schemaker/models/base_model.rb', line 33 def clazz_name my_class.to_s end |
#configure ⇒ Object
The models :subject and :object must both be configured with a has_many relationship to the join model which the has_many :through references
27 28 29 |
# File 'lib/schemaker/models/base_model.rb', line 27 def configure create_has_many :join, class_name_option(join_class) end |