Class: Metasploit::ERD::Relationship
- Inherits:
-
Object
- Object
- Metasploit::ERD::Relationship
- Defined in:
- lib/metasploit/erd/relationship.rb
Overview
The relationship in an Entity-Relationship Diagram. Modelled using an #association extracted from a
Class<ActiveRecord::Base>
using reflection.
Instance Attribute Summary collapse
-
#association ⇒ ActiveRecord::Associations::BelongsToAssociation
readonly
A
belongs_to
association.
Instance Method Summary collapse
-
#class_set ⇒ Set<Class<ActiveRecord::Base>>
Set of classes pointed to by this association.
-
#initialize(association) ⇒ Relationship
constructor
A new instance of Relationship.
Constructor Details
#initialize(association) ⇒ Relationship
Returns a new instance of Relationship.
20 21 22 |
# File 'lib/metasploit/erd/relationship.rb', line 20 def initialize(association) @association = association end |
Instance Attribute Details
#association ⇒ ActiveRecord::Associations::BelongsToAssociation (readonly)
A belongs_to
association.
8 9 10 |
# File 'lib/metasploit/erd/relationship.rb', line 8 def association @association end |
Instance Method Details
#class_set ⇒ Set<Class<ActiveRecord::Base>>
Set of classes pointed to by this association. Differs from association.klass
as #class_set properly handles
polymorphic associations by finding all Class<ActiveRecord::Base>
that has_many <inverse>, as: <name>
and so
can fulfill belongs_to <name>, polymorpic: true
.
29 30 31 32 33 34 35 |
# File 'lib/metasploit/erd/relationship.rb', line 29 def class_set if association.[:polymorphic] polymorphic_class_set else Set.new([association.klass]) end end |