Class: Opencdd::Entity::VersionHistory
- Inherits:
-
Object
- Object
- Opencdd::Entity::VersionHistory
- Includes:
- Enumerable
- Defined in:
- lib/opencdd/entity/version_history.rb
Overview
Model object for the per-version provenance captured in
downloads/<dict>/<CODE>/_entity.json#versions. Each entry
represents one historical version of the entity: which version
and revision it was, its status at that point, who committed it,
and the change-request ID.
The ShardedDirReader parses _entity.json for each class subdir
and attaches a VersionHistory to every entity it creates. The
Json exporter then emits it as an array of version entries,
matching the IEC CDD "Version history" section on detail pages.
Defined Under Namespace
Classes: Entry
Instance Attribute Summary collapse
-
#entries ⇒ Object
readonly
Returns the value of attribute entries.
Instance Method Summary collapse
- #attach(entry) ⇒ Object
- #current ⇒ Object
- #each(&block) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(entries = []) ⇒ VersionHistory
constructor
A new instance of VersionHistory.
- #previous ⇒ Object
- #size ⇒ Object
- #to_a ⇒ Object
Constructor Details
#initialize(entries = []) ⇒ VersionHistory
Returns a new instance of VersionHistory.
26 27 28 |
# File 'lib/opencdd/entity/version_history.rb', line 26 def initialize(entries = []) @entries = Array(entries) end |
Instance Attribute Details
#entries ⇒ Object (readonly)
Returns the value of attribute entries.
30 31 32 |
# File 'lib/opencdd/entity/version_history.rb', line 30 def entries @entries end |
Instance Method Details
#attach(entry) ⇒ Object
56 57 58 59 |
# File 'lib/opencdd/entity/version_history.rb', line 56 def attach(entry) @entries << entry self end |
#current ⇒ Object
44 45 46 |
# File 'lib/opencdd/entity/version_history.rb', line 44 def current @entries.find(&:current?) || @entries.first end |
#each(&block) ⇒ Object
32 33 34 |
# File 'lib/opencdd/entity/version_history.rb', line 32 def each(&block) @entries.each(&block) end |
#empty? ⇒ Boolean
40 41 42 |
# File 'lib/opencdd/entity/version_history.rb', line 40 def empty? @entries.empty? end |
#previous ⇒ Object
48 49 50 |
# File 'lib/opencdd/entity/version_history.rb', line 48 def previous @entries.reject { |e| e == current } end |
#size ⇒ Object
36 37 38 |
# File 'lib/opencdd/entity/version_history.rb', line 36 def size @entries.size end |
#to_a ⇒ Object
52 53 54 |
# File 'lib/opencdd/entity/version_history.rb', line 52 def to_a @entries.dup end |