Skip to content

Commit

Permalink
Delay load manageiq-api-client until needed
Browse files Browse the repository at this point in the history
We can require this when needed instead of eager loading it when Vm or other
models load it.
  • Loading branch information
jrafanie committed Feb 27, 2020
1 parent 67c2962 commit 973a3a7
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
3 changes: 1 addition & 2 deletions app/models/mixins/inter_region_api_method_relay.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require 'manageiq-api-client'

module InterRegionApiMethodRelay
class InterRegionApiMethodRelayError < RuntimeError; end

Expand Down Expand Up @@ -54,6 +52,7 @@ def api_relay_class_method(method, action = method)
end

def self.api_client_connection_for_region(region_number, user = User.current_userid)
require 'manageiq-api-client'
region = MiqRegion.find_by(:region => region_number)

url = region.remote_ws_url
Expand Down
3 changes: 1 addition & 2 deletions app/models/mixins/process_tasks_mixin.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require 'manageiq-api-client'

module ProcessTasksMixin
extend ActiveSupport::Concern
include RetirementMixin
Expand Down Expand Up @@ -128,6 +126,7 @@ def invoke_api_tasks(api_client, remote_options)
end

def send_action(action, collection_name, collection, remote_options, id = nil)
require 'manageiq-api-client'
post_args = remote_options[:args] || {}
begin
if id.present?
Expand Down
2 changes: 2 additions & 0 deletions spec/models/mixins/inter_region_api_method_relay_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'manageiq-api-client'

RSpec.describe InterRegionApiMethodRelay do
let(:collection_name) { :test_class_collection }
let(:api_config) { double("Api::CollectionConfig") }
Expand Down
2 changes: 2 additions & 0 deletions spec/models/mixins/process_tasks_mixin_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'manageiq-api-client'

RSpec.describe ProcessTasksMixin do
let(:test_class) do
Class.new(ApplicationRecord) do
Expand Down

0 comments on commit 973a3a7

Please sign in to comment.