Class: Pferd::Entity
- Inherits:
-
Object
- Object
- Pferd::Entity
- Defined in:
- lib/pferd/entity.rb
Instance Attribute Summary collapse
-
#associations ⇒ Object
Returns the value of attribute associations.
-
#domain ⇒ Object
Returns the value of attribute domain.
-
#klass_name ⇒ Object
(also: #name)
Returns the value of attribute klass_name.
Instance Method Summary collapse
- #add_relationship(name:, domain:) ⇒ Object
-
#initialize(klass_name, associations, domain) ⇒ Entity
constructor
A new instance of Entity.
- #to_h ⇒ Object
Constructor Details
#initialize(klass_name, associations, domain) ⇒ Entity
Returns a new instance of Entity.
8 9 10 11 12 |
# File 'lib/pferd/entity.rb', line 8 def initialize(klass_name, associations, domain) @klass_name = klass_name @associations = Set.new @domain = domain end |
Instance Attribute Details
#associations ⇒ Object
Returns the value of attribute associations.
5 6 7 |
# File 'lib/pferd/entity.rb', line 5 def associations @associations end |
#domain ⇒ Object
Returns the value of attribute domain.
5 6 7 |
# File 'lib/pferd/entity.rb', line 5 def domain @domain end |
#klass_name ⇒ Object Also known as: name
Returns the value of attribute klass_name.
5 6 7 |
# File 'lib/pferd/entity.rb', line 5 def klass_name @klass_name end |
Instance Method Details
#add_relationship(name:, domain:) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/pferd/entity.rb', line 14 def add_relationship(name: , domain: ) boundary_violation = self.domain != domain associations.add( EntityRelationship.new(name:, domain:, boundary_violation: boundary_violation) ) end |
#to_h ⇒ Object
20 21 22 |
# File 'lib/pferd/entity.rb', line 20 def to_h { entity: klass_name, domain: domain, associations: associations.map(&:to_h) } end |