Module: RSMP::Components

Included in:
Site, SiteProxy
Defined in:
lib/rsmp/components.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#componentsObject (readonly)

Returns the value of attribute components.


5
6
7
# File 'lib/rsmp/components.rb', line 5

def components
  @components
end

Instance Method Details

#add_component(component) ⇒ Object


23
24
25
# File 'lib/rsmp/components.rb', line 23

def add_component component
  @components[component.c_id] = component
end

#aggregated_status_changed(component, options = {}) ⇒ Object


11
12
# File 'lib/rsmp/components.rb', line 11

def aggregated_status_changed component, options={}
end

#build_component(id:, type:, settings: {}) ⇒ Object


27
28
29
# File 'lib/rsmp/components.rb', line 27

def build_component id:, type:, settings:{}
  Component.new id:id, node: self, grouped: type=='main'
end

#find_component(component_id) ⇒ Object

Raises:


31
32
33
34
35
# File 'lib/rsmp/components.rb', line 31

def find_component component_id
  component = @components[component_id]
  raise UnknownComponent.new("Component #{component_id} not found") unless component
  component
end

#initialize_componentsObject


7
8
9
# File 'lib/rsmp/components.rb', line 7

def initialize_components
  @components = {}
end

#setup_components(settings) ⇒ Object


14
15
16
17
18
19
20
21
# File 'lib/rsmp/components.rb', line 14

def setup_components settings
  return unless settings
  settings.each_pair do |type,components_by_type|
    components_by_type.each_pair do |id,settings|
      @components[id] = build_component(id:id, type:type, settings:settings)
    end
  end
end