Class: Dbwatcher::Services::DiagramData::RelationshipParams
- Inherits:
-
Object
- Object
- Dbwatcher::Services::DiagramData::RelationshipParams
- Defined in:
- lib/dbwatcher/services/diagram_data/relationship_params.rb
Overview
Parameter object for relationship creation
This class encapsulates parameters used for creating relationships to avoid long parameter lists.
Instance Attribute Summary collapse
-
#cardinality ⇒ Object
Returns the value of attribute cardinality.
-
#label ⇒ Object
Returns the value of attribute label.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#source_id ⇒ Object
Returns the value of attribute source_id.
-
#target_id ⇒ Object
Returns the value of attribute target_id.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
-
.create(params) ⇒ RelationshipParams
Create from individual parameters.
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ RelationshipParams
constructor
Initialize relationship parameters.
-
#to_h ⇒ Hash
Convert to hash.
Constructor Details
#initialize(params = {}) ⇒ RelationshipParams
Initialize relationship parameters
22 23 24 25 26 27 28 29 |
# File 'lib/dbwatcher/services/diagram_data/relationship_params.rb', line 22 def initialize(params = {}) @source_id = params[:source_id] @target_id = params[:target_id] @type = params[:type] @label = params[:label] @cardinality = params[:cardinality] @metadata = params[:metadata] || {} end |
Instance Attribute Details
#cardinality ⇒ Object
Returns the value of attribute cardinality.
11 12 13 |
# File 'lib/dbwatcher/services/diagram_data/relationship_params.rb', line 11 def cardinality @cardinality end |
#label ⇒ Object
Returns the value of attribute label.
11 12 13 |
# File 'lib/dbwatcher/services/diagram_data/relationship_params.rb', line 11 def label @label end |
#metadata ⇒ Object
Returns the value of attribute metadata.
11 12 13 |
# File 'lib/dbwatcher/services/diagram_data/relationship_params.rb', line 11 def @metadata end |
#source_id ⇒ Object
Returns the value of attribute source_id.
11 12 13 |
# File 'lib/dbwatcher/services/diagram_data/relationship_params.rb', line 11 def source_id @source_id end |
#target_id ⇒ Object
Returns the value of attribute target_id.
11 12 13 |
# File 'lib/dbwatcher/services/diagram_data/relationship_params.rb', line 11 def target_id @target_id end |
#type ⇒ Object
Returns the value of attribute type.
11 12 13 |
# File 'lib/dbwatcher/services/diagram_data/relationship_params.rb', line 11 def type @type end |
Class Method Details
.create(params) ⇒ RelationshipParams
Create from individual parameters
35 36 37 |
# File 'lib/dbwatcher/services/diagram_data/relationship_params.rb', line 35 def self.create(params) new(params) end |
Instance Method Details
#to_h ⇒ Hash
Convert to hash
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/dbwatcher/services/diagram_data/relationship_params.rb', line 42 def to_h { source_id: source_id, target_id: target_id, type: type, label: label, cardinality: cardinality, metadata: } end |