class DBDiagram::Domain::Entity
Entities represent your Active Record models. Entities may be connected to other entities.
Attributes
The domain in which this entity resides.
The Active Record model that this entity corresponds to.
The name of this entity. Equal to the class name of the corresponding model (for concrete entities) or given name (for abstract entities).
Private Class Methods
# File lib/db_diagram/domain/entity.rb, line 13 def concrete_from_models(domain, models) models.collect { |model| new(domain, model) } end
Public Instance Methods
Returns true
if this entity does not correspond directly with a database table (if and only if the entity is specialized or generalized).
# File lib/db_diagram/domain/entity.rb, line 60 def abstract? generalized? end
Returns an array of attributes for this entity.
# File lib/db_diagram/domain/entity.rb, line 37 def attributes @attributes ||= generalized? ? [] : Attribute.from_model(domain, model) end
Returns true
if this entity is a generalization, which does not correspond with a database table. Generalized entities are either models that are defined as abstract_class
or they are constructed from polymorphic interfaces. Any has_one
or has_many
association that defines a polymorphic interface with :as => :name
will lead to a generalized entity to be created.
# File lib/db_diagram/domain/entity.rb, line 53 def generalized? !!model.abstract_class? end
# File lib/db_diagram/domain/entity.rb, line 68 def model_name model.name end
# File lib/db_diagram/domain/entity.rb, line 64 def namespace $1 if name.match(/(.*)::.*/) end
Returns an array of all relationships that this entity has with other entities in the domain model.
# File lib/db_diagram/domain/entity.rb, line 43 def relationships domain.relationships_by_entity_name(name) end