Class: ReactorSDK::Resources::UpstreamChain

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/reactor_sdk/resources/upstream_chain.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource_id:, resource_type:, property_id:, target_library_id:, target_resource:, target_revision_id:, entries:) ⇒ UpstreamChain

Returns a new instance of UpstreamChain.



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/reactor_sdk/resources/upstream_chain.rb', line 28

def initialize(
  resource_id:,
  resource_type:,
  property_id:,
  target_library_id:,
  target_resource:,
  target_revision_id:,
  entries:
)
  @resource_id = resource_id
  @resource_type = resource_type
  @property_id = property_id
  @target_library_id = target_library_id
  @target_resource = target_resource
  @target_revision_id = target_revision_id
  @entries = Array(entries)
end

Instance Attribute Details

#entriesObject (readonly)

Returns the value of attribute entries.



20
21
22
# File 'lib/reactor_sdk/resources/upstream_chain.rb', line 20

def entries
  @entries
end

#property_idObject (readonly)

Returns the value of attribute property_id.



20
21
22
# File 'lib/reactor_sdk/resources/upstream_chain.rb', line 20

def property_id
  @property_id
end

#resource_idObject (readonly)

Returns the value of attribute resource_id.



20
21
22
# File 'lib/reactor_sdk/resources/upstream_chain.rb', line 20

def resource_id
  @resource_id
end

#resource_typeObject (readonly)

Returns the value of attribute resource_type.



20
21
22
# File 'lib/reactor_sdk/resources/upstream_chain.rb', line 20

def resource_type
  @resource_type
end

#target_library_idObject (readonly)

Returns the value of attribute target_library_id.



20
21
22
# File 'lib/reactor_sdk/resources/upstream_chain.rb', line 20

def target_library_id
  @target_library_id
end

#target_resourceObject (readonly)

Returns the value of attribute target_resource.



20
21
22
# File 'lib/reactor_sdk/resources/upstream_chain.rb', line 20

def target_resource
  @target_resource
end

#target_revision_idObject (readonly)

Returns the value of attribute target_revision_id.



20
21
22
# File 'lib/reactor_sdk/resources/upstream_chain.rb', line 20

def target_revision_id
  @target_revision_id
end

Instance Method Details

#each {|entry| ... } ⇒ Array<ReactorSDK::Resources::UpstreamChainEntry>



50
51
52
# File 'lib/reactor_sdk/resources/upstream_chain.rb', line 50

def each(&)
  @entries.each(&)
end

#found?Boolean

Returns true when any upstream library contains the resource.

Returns:

  • (Boolean)

    true when any upstream library contains the resource



64
65
66
# File 'lib/reactor_sdk/resources/upstream_chain.rb', line 64

def found?
  !nearest_match.nil?
end

#inspectString

Returns Human-readable representation.

Returns:

  • (String)

    Human-readable representation



71
72
73
74
75
76
77
# File 'lib/reactor_sdk/resources/upstream_chain.rb', line 71

def inspect
  '#<ReactorSDK::Resources::UpstreamChain ' \
    "resource_id=#{resource_id.inspect} " \
    "resource_type=#{resource_type.inspect} " \
    "target_library_id=#{target_library_id.inspect} " \
    "entries=#{entries.length}>"
end

#nearest_matchReactorSDK::Resources::UpstreamChainEntry?



57
58
59
# File 'lib/reactor_sdk/resources/upstream_chain.rb', line 57

def nearest_match
  @entries.find(&:present?)
end