Class: ReactorSDK::Resources::LibrarySnapshot
- Inherits:
-
Object
- Object
- ReactorSDK::Resources::LibrarySnapshot
- Defined in:
- lib/reactor_sdk/resources/library_snapshot.rb
Instance Attribute Summary collapse
-
#data_elements ⇒ Object
readonly
Returns the value of attribute data_elements.
-
#extensions ⇒ Object
readonly
Returns the value of attribute extensions.
-
#library ⇒ Object
readonly
Returns the value of attribute library.
-
#property_id ⇒ Object
readonly
Returns the value of attribute property_id.
-
#resource_by_id ⇒ Object
readonly
Returns the value of attribute resource_by_id.
-
#rule_components ⇒ Object
readonly
Returns the value of attribute rule_components.
-
#rule_components_by_rule_id ⇒ Object
readonly
Returns the value of attribute rule_components_by_rule_id.
-
#rules ⇒ Object
readonly
Returns the value of attribute rules.
Instance Method Summary collapse
- #all_resources ⇒ Object
- #comprehensive_resource(resource_id, resource_type: nil) ⇒ Object
- #data_elements_for_extension(extension_or_id) ⇒ Object
- #find_resource(resource_id) ⇒ Object
- #impacted_rules_for(data_element_or_id) ⇒ Object
-
#initialize(property_id:, library:, rule_components_by_rule_id:) ⇒ LibrarySnapshot
constructor
A new instance of LibrarySnapshot.
- #referenced_data_elements_for(data_element_or_id) ⇒ Object
- #resource_revision_id(resource_or_id) ⇒ Object
- #rule_components_for_extension(extension_or_id) ⇒ Object
- #rule_components_for_rule(rule_or_id) ⇒ Object
- #rules_for_extension(extension_or_id) ⇒ Object
- #top_level_resources ⇒ Object
Constructor Details
#initialize(property_id:, library:, rule_components_by_rule_id:) ⇒ LibrarySnapshot
Returns a new instance of LibrarySnapshot.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/reactor_sdk/resources/library_snapshot.rb', line 15 def initialize(property_id:, library:, rule_components_by_rule_id:) @property_id = property_id @library = library @rules = Array(library.rules) @data_elements = Array(library.data_elements) @extensions = Array(library.extensions) @index = LibrarySnapshotIndex.new( rules: @rules, data_elements: @data_elements, extensions: @extensions, rule_components_by_rule_id: rule_components_by_rule_id ) @rule_components_by_rule_id = @index.rule_components_by_rule_id @rule_components = @index.rule_components @resource_by_id = @index.resource_by_id end |
Instance Attribute Details
#data_elements ⇒ Object (readonly)
Returns the value of attribute data_elements.
6 7 8 |
# File 'lib/reactor_sdk/resources/library_snapshot.rb', line 6 def data_elements @data_elements end |
#extensions ⇒ Object (readonly)
Returns the value of attribute extensions.
6 7 8 |
# File 'lib/reactor_sdk/resources/library_snapshot.rb', line 6 def extensions @extensions end |
#library ⇒ Object (readonly)
Returns the value of attribute library.
6 7 8 |
# File 'lib/reactor_sdk/resources/library_snapshot.rb', line 6 def library @library end |
#property_id ⇒ Object (readonly)
Returns the value of attribute property_id.
6 7 8 |
# File 'lib/reactor_sdk/resources/library_snapshot.rb', line 6 def property_id @property_id end |
#resource_by_id ⇒ Object (readonly)
Returns the value of attribute resource_by_id.
6 7 8 |
# File 'lib/reactor_sdk/resources/library_snapshot.rb', line 6 def resource_by_id @resource_by_id end |
#rule_components ⇒ Object (readonly)
Returns the value of attribute rule_components.
6 7 8 |
# File 'lib/reactor_sdk/resources/library_snapshot.rb', line 6 def rule_components @rule_components end |
#rule_components_by_rule_id ⇒ Object (readonly)
Returns the value of attribute rule_components_by_rule_id.
6 7 8 |
# File 'lib/reactor_sdk/resources/library_snapshot.rb', line 6 def rule_components_by_rule_id @rule_components_by_rule_id end |
#rules ⇒ Object (readonly)
Returns the value of attribute rules.
6 7 8 |
# File 'lib/reactor_sdk/resources/library_snapshot.rb', line 6 def rules @rules end |
Instance Method Details
#all_resources ⇒ Object
36 37 38 |
# File 'lib/reactor_sdk/resources/library_snapshot.rb', line 36 def all_resources top_level_resources + @rule_components end |
#comprehensive_resource(resource_id, resource_type: nil) ⇒ Object
79 80 81 82 83 84 |
# File 'lib/reactor_sdk/resources/library_snapshot.rb', line 79 def comprehensive_resource(resource_id, resource_type: nil) resource = find_resource(resource_id) return nil if resource.nil? build_comprehensive_resource(resource, resource_type || resource.type) end |
#data_elements_for_extension(extension_or_id) ⇒ Object
56 57 58 |
# File 'lib/reactor_sdk/resources/library_snapshot.rb', line 56 def data_elements_for_extension(extension_or_id) @index.data_elements_for_extension(extension_or_id) end |
#find_resource(resource_id) ⇒ Object
40 41 42 |
# File 'lib/reactor_sdk/resources/library_snapshot.rb', line 40 def find_resource(resource_id) @index.find_resource(resource_id) end |
#impacted_rules_for(data_element_or_id) ⇒ Object
52 53 54 |
# File 'lib/reactor_sdk/resources/library_snapshot.rb', line 52 def impacted_rules_for(data_element_or_id) @index.impacted_rules_for(data_element_or_id) end |
#referenced_data_elements_for(data_element_or_id) ⇒ Object
48 49 50 |
# File 'lib/reactor_sdk/resources/library_snapshot.rb', line 48 def referenced_data_elements_for(data_element_or_id) @index.referenced_data_elements_for(data_element_or_id) end |
#resource_revision_id(resource_or_id) ⇒ Object
68 69 70 71 72 73 74 75 76 77 |
# File 'lib/reactor_sdk/resources/library_snapshot.rb', line 68 def resource_revision_id(resource_or_id) resource_id = extract_id(resource_or_id) resource = find_resource(resource_id) return nil if resource.nil? return resource.revision_id if resource.respond_to?(:revision_id) return @library.resource_index[resource_id] if @library.resource_index.key?(resource_id) return resource.relationship_id('latest_revision') if resource.respond_to?(:relationship_id) nil end |
#rule_components_for_extension(extension_or_id) ⇒ Object
60 61 62 |
# File 'lib/reactor_sdk/resources/library_snapshot.rb', line 60 def rule_components_for_extension(extension_or_id) @index.rule_components_for_extension(extension_or_id) end |
#rule_components_for_rule(rule_or_id) ⇒ Object
44 45 46 |
# File 'lib/reactor_sdk/resources/library_snapshot.rb', line 44 def rule_components_for_rule(rule_or_id) @index.rule_components_for_rule(rule_or_id) end |
#rules_for_extension(extension_or_id) ⇒ Object
64 65 66 |
# File 'lib/reactor_sdk/resources/library_snapshot.rb', line 64 def rules_for_extension(extension_or_id) @index.rules_for_extension(extension_or_id) end |
#top_level_resources ⇒ Object
32 33 34 |
# File 'lib/reactor_sdk/resources/library_snapshot.rb', line 32 def top_level_resources @top_level_resources ||= @rules + @data_elements + @extensions end |