Class: BazaModels::Model::Reflection
- Inherits:
-
Object
- Object
- BazaModels::Model::Reflection
- Defined in:
- lib/baza_models/model/reflection.rb
Instance Method Summary collapse
- #class_name ⇒ Object
- #collection? ⇒ Boolean
- #foreign_key ⇒ Object
-
#initialize(relationship) ⇒ Reflection
constructor
A new instance of Reflection.
- #klass ⇒ Object
- #name ⇒ Object
Constructor Details
#initialize(relationship) ⇒ Reflection
Returns a new instance of Reflection.
2 3 4 |
# File 'lib/baza_models/model/reflection.rb', line 2 def initialize(relationship) @relationship = relationship end |
Instance Method Details
#class_name ⇒ Object
6 7 8 |
# File 'lib/baza_models/model/reflection.rb', line 6 def class_name @relationship.fetch(:class_name) end |
#collection? ⇒ Boolean
10 11 12 |
# File 'lib/baza_models/model/reflection.rb', line 10 def collection? @relationship.fetch(:type) == :has_many end |
#foreign_key ⇒ Object
14 15 16 |
# File 'lib/baza_models/model/reflection.rb', line 14 def foreign_key @relationship.fetch(:foreign_key).to_s end |
#klass ⇒ Object
18 19 20 |
# File 'lib/baza_models/model/reflection.rb', line 18 def klass StringCases.constantize(class_name) end |
#name ⇒ Object
22 23 24 |
# File 'lib/baza_models/model/reflection.rb', line 22 def name @relationship.fetch(:relation_name) end |