Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace alias_method_chain with Module.prepend #6

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions app/models/concerns/fog_extensions/azurerm/servers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,22 @@ module AzureRM
module Servers
extend ActiveSupport::Concern

included do
alias_method_chain :all, :patched_arguments
alias_method_chain :get, :patched_arguments
end
module Overrides
def all(_options = {})
super()
end

def all_with_patched_arguments(_options = {})
all_without_patched_arguments
def get(uuid)
raw_vm = service.list_all_vms.find { |vm| vm.name == uuid }
virtual_machine_fog = Fog::Compute::AzureRM::Server.new(service: service)
vm_hash = Fog::Compute::AzureRM::Server.parse(raw_vm)
virtual_machine_fog.merge_attributes(vm_hash)
end
end

def get_with_patched_arguments(uuid)
raw_vm = service.list_all_vms.find { |vm| vm.name == uuid }
virtual_machine_fog = Fog::Compute::AzureRM::Server.new(service: service)
vm_hash = Fog::Compute::AzureRM::Server.parse(raw_vm)
virtual_machine_fog.merge_attributes(vm_hash)
included do
prepend Overrides
end
end
end
end
end
4 changes: 2 additions & 2 deletions lib/foreman_azure_rm/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class Engine < ::Rails::Engine

initializer 'foreman_azure_rm.register_plugin', :before => :finisher_hook do
Foreman::Plugin.register :foreman_azure_rm do
requires_foreman '>= 1.14'
requires_foreman '>= 1.17'
compute_resource ForemanAzureRM::AzureRM
end
end
Expand Down Expand Up @@ -79,4 +79,4 @@ class Engine < ::Rails::Engine
Fog::Compute::AzureRM::ManagedDisks.send(:include, FogExtensions::AzureRM::ManagedDisks)
end
end
end
end