Class: ForemanNetbox::CachedNetboxParameters

Inherits:
Object
  • Object
show all
Defined in:
app/services/foreman_netbox/cached_netbox_parameters.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host) ⇒ CachedNetboxParameters

Returns a new instance of CachedNetboxParameters.



9
10
11
12
13
# File 'app/services/foreman_netbox/cached_netbox_parameters.rb', line 9

def initialize(host)
  @is_compute = host.compute?
  @data = host.netbox_facet.raw_data&.deep_symbolize_keys || {}
  @result = {}
end

Class Method Details

.call(host) ⇒ Object



5
6
7
# File 'app/services/foreman_netbox/cached_netbox_parameters.rb', line 5

def self.call(host)
  new(host).call
end

Instance Method Details

#callObject



15
16
17
18
19
20
# File 'app/services/foreman_netbox/cached_netbox_parameters.rb', line 15

def call
  additional_params = is_compute ? ForemanNetbox::NetboxFacet::VIRTUAL_MACHINE_PARAMS : ForemanNetbox::NetboxFacet::DEVICE_PARAMS
  (ForemanNetbox::NetboxFacet::COMMON_PARAMS + additional_params).map { |key| send("read_#{key}") }

  result
end