Class: RailsGraph::Graph::Relationship
- Defined in:
- lib/rails_graph/graph/relationship.rb
Direct Known Subclasses
RailsGraph::Graph::Relationships::Association, RailsGraph::Graph::Relationships::Attribute, RailsGraph::Graph::Relationships::Inheritance, RailsGraph::Graph::Relationships::PackDependency, RailsGraph::Graph::Relationships::PackModel
Instance Attribute Summary collapse
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Attributes inherited from Entity
Instance Method Summary collapse
- #as_json(_options = nil) ⇒ Object
- #identifier ⇒ Object
-
#initialize(source:, target:, label:, **opts) ⇒ Relationship
constructor
A new instance of Relationship.
Constructor Details
#initialize(source:, target:, label:, **opts) ⇒ Relationship
Returns a new instance of Relationship.
10 11 12 13 14 15 16 |
# File 'lib/rails_graph/graph/relationship.rb', line 10 def initialize(source:, target:, label:, **opts) @source = source @target = target @label = label super(**opts) end |
Instance Attribute Details
#label ⇒ Object (readonly)
Returns the value of attribute label.
8 9 10 |
# File 'lib/rails_graph/graph/relationship.rb', line 8 def label @label end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
8 9 10 |
# File 'lib/rails_graph/graph/relationship.rb', line 8 def source @source end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
8 9 10 |
# File 'lib/rails_graph/graph/relationship.rb', line 8 def target @target end |
Instance Method Details
#as_json(_options = nil) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rails_graph/graph/relationship.rb', line 22 def as_json( = nil) { id: id, label: label, name: name, source: source.id, target: target.id, properties: properties } end |
#identifier ⇒ Object
18 19 20 |
# File 'lib/rails_graph/graph/relationship.rb', line 18 def identifier "#{label}##{source.identifier}##{target.identifier}##{name}" end |