Class: PuppetX::Puppetlabs::Migration::OverviewModel::Entity Abstract
- Inherits:
-
Object
- Object
- PuppetX::Puppetlabs::Migration::OverviewModel::Entity
- Includes:
- ModelObject
- Defined in:
- lib/puppet_x/puppetlabs/migration/overview_model.rb
Overview
Abstract base class for all entities in the overview model.
Direct Known Subclasses
AttributeIssue, Compilation, IssueOnNode, Location, LogEntry, LogMessage, NamedEntity, NodeIssue, SourceFile
Class Method Summary collapse
- .from_hash(hash) ⇒ Object
- .init_relationships ⇒ Object private
- .many_relationship(name) ⇒ Object private
- .many_rels_hash ⇒ Object private
-
.simple_name ⇒ String
Returns the last segment of the qualified class name.
Instance Method Summary collapse
- #<=>(o) ⇒ Object
- #eql?(o) ⇒ Boolean (also: #==)
- #hash ⇒ Object
- #id ⇒ Object
-
#initialize(id) ⇒ Entity
constructor
A new instance of Entity.
-
#many_relationship(name) ⇒ UnboundMethod, ...
private
Returns an object that can be used when retrieving the target collection of the relationship denoted by the given name or ‘nil` if no such relationship exists.
-
#one_relationship(name) ⇒ Method?
private
Returns the id of the target entity in the relationship identified by the given name or ‘nil` if no such relationship exists.
Methods included from ModelObject
#initialize_from_hash, #to_hash
Constructor Details
#initialize(id) ⇒ Entity
Returns a new instance of Entity.
49 50 51 |
# File 'lib/puppet_x/puppetlabs/migration/overview_model.rb', line 49 def initialize(id) @_id = id end |
Class Method Details
.from_hash(hash) ⇒ Object
16 17 18 19 20 |
# File 'lib/puppet_x/puppetlabs/migration/overview_model.rb', line 16 def self.from_hash(hash) instance = allocate instance.initialize_from_hash(hash) instance.freeze end |
.init_relationships ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
36 37 38 |
# File 'lib/puppet_x/puppetlabs/migration/overview_model.rb', line 36 def self.init_relationships @relationships = many_rels_hash end |
.many_relationship(name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
31 32 33 |
# File 'lib/puppet_x/puppetlabs/migration/overview_model.rb', line 31 def self.many_relationship(name) @relationships[name] end |
.many_rels_hash ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
41 42 43 |
# File 'lib/puppet_x/puppetlabs/migration/overview_model.rb', line 41 def self.many_rels_hash EMPTY_HASH end |
.simple_name ⇒ String
Returns the last segment of the qualified class name
26 27 28 |
# File 'lib/puppet_x/puppetlabs/migration/overview_model.rb', line 26 def self.simple_name name.rpartition(DOUBLE_COLON)[2] end |
Instance Method Details
#<=>(o) ⇒ Object
57 58 59 |
# File 'lib/puppet_x/puppetlabs/migration/overview_model.rb', line 57 def <=>(o) o.is_a?(Entity) ? @_id <=> o.id : nil end |
#eql?(o) ⇒ Boolean Also known as: ==
61 62 63 |
# File 'lib/puppet_x/puppetlabs/migration/overview_model.rb', line 61 def eql?(o) o.is_a?(Entity) && @_id == o.id end |
#hash ⇒ Object
53 54 55 |
# File 'lib/puppet_x/puppetlabs/migration/overview_model.rb', line 53 def hash @_id.hash end |
#id ⇒ Object
45 46 47 |
# File 'lib/puppet_x/puppetlabs/migration/overview_model.rb', line 45 def id @_id end |
#many_relationship(name) ⇒ UnboundMethod, ...
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns an object that can be used when retrieving the target collection of the relationship denoted by the given name or ‘nil` if no such relationship exists.
The returned object is either the UnboundMethod that, when bound to entities of the target class will yield the id that should be compared with the id of the source entity, or an array where the first element is the method and subsequent elements may be either UnboundMethod instances of symbols.
The array form is used when traversing though intermediate tables. An UnboundMethod is used in the same way as the non-array form and the symbol denotes the method to use to retrieve the final id from the previously found entities (or entities).
94 95 96 |
# File 'lib/puppet_x/puppetlabs/migration/overview_model.rb', line 94 def many_relationship(name) self.class.many_relationship(name) end |
#one_relationship(name) ⇒ Method?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the id of the target entity in the relationship identified by the given name or ‘nil` if no such relationship exists. An existing relationship with an undefined value is represented by the constant `UNDEFINED_ID`.
75 76 |
# File 'lib/puppet_x/puppetlabs/migration/overview_model.rb', line 75 def one_relationship(name) end |