Class: Schemaker::BaseModel
- Inherits:
-
Object
- Object
- Schemaker::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.
15 16 17 18 19 20 21 22 |
# File 'lib/schemaker/models/base_model.rb', line 15 def initialize models, my_class raise ArgumentError, "The first argument must be a Schema::Models instance" if !models.is_a?(Schemaker::Models) raise ArgumentError, "The second argument must be the Class that is to be configured" 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
11 12 13 |
# File 'lib/schemaker/models/base_model.rb', line 11 def logs @logs end |
#models ⇒ Object
Returns the value of attribute models.
10 11 12 |
# File 'lib/schemaker/models/base_model.rb', line 10 def models @models end |
#my_class ⇒ Object
Returns the value of attribute my_class.
10 11 12 |
# File 'lib/schemaker/models/base_model.rb', line 10 def my_class @my_class end |
Class Method Details
.model_types ⇒ Object
37 38 39 |
# File 'lib/schemaker/models/base_model.rb', line 37 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
32 33 34 |
# File 'lib/schemaker/models/base_model.rb', line 32 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
26 27 28 |
# File 'lib/schemaker/models/base_model.rb', line 26 def configure create_has_many :join, class_name_option(join_class) end |