Class: PuppetX::Puppetlabs::Migration::OverviewModel::Entity Abstract

Inherits:
Object
  • Object
show all
Includes:
ModelObject
Defined in:
lib/puppet_x/puppetlabs/migration/overview_model.rb

Overview

This class is abstract.

Abstract base class for all entities in the overview model.

Class Method Summary collapse

Instance Method Summary collapse

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_relationshipsObject

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_hashObject

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_nameString

Returns the last segment of the qualified class name

Returns:

  • (String)

    the name of the class without the module prefix



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: ==

Returns:

  • (Boolean)


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

#hashObject



53
54
55
# File 'lib/puppet_x/puppetlabs/migration/overview_model.rb', line 53

def hash
  @_id.hash
end

#idObject



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).

Parameters:

  • name (Symbol)

Returns:

  • (UnboundMethod, Array<UnboundMethod,Symbol>, nil)

    the get method or array with get method and symbol, or nil



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`.

Parameters:

  • name (Symbol)

Returns:

  • (Method, nil)

    the get method or array with get method and symbol, or nil



75
76
# File 'lib/puppet_x/puppetlabs/migration/overview_model.rb', line 75

def one_relationship(name)
end