Class: MiqAeMethodService::MiqAeServiceGenericObject

Inherits:
MiqAeServiceModelBase show all
Defined in:
lib/miq_automation_engine/service_models/miq_ae_service_generic_object.rb

Constant Summary

Constants inherited from MiqAeServiceModelBase

MiqAeMethodService::MiqAeServiceModelBase::DELIMS, MiqAeMethodService::MiqAeServiceModelBase::EXPOSED_ATTR_BLACK_LIST, MiqAeMethodService::MiqAeServiceModelBase::SERVICE_MODEL_GLOB, MiqAeMethodService::MiqAeServiceModelBase::SERVICE_MODEL_PATH, MiqAeMethodService::MiqAeServiceModelBase::UNWISE

Instance Method Summary collapse

Methods inherited from MiqAeServiceModelBase

ar_base_model, ar_method, #ar_method, association, association=, associations, #associations, base_class, base_model, inherited, #initialize, #inspect, #inspect_all, method_missing, model_name_from_active_record_model, model_name_from_file, #model_suffix, normalize, #object_class, #object_send, #reload, respond_to_missing?, service_models, #tag_assign, #tag_unassign, taggable?, #taggable?, #tagged_with?, #tags, #virtual_column_names, #virtual_columns_inspect, #wrap_results, wrap_results

Methods included from Vmdb::Logging

#_log

Methods included from MiqAeServiceObjectCommon

#[], #[]=, #attributes, #attributes=, #class_name, #current_field_name, #current_field_type, #current_message, #decrypt, #id, #instance_name, #name, #namespace, #parent

Constructor Details

This class inherits a constructor from MiqAeMethodService::MiqAeServiceModelBase

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args) ⇒ Object (private)


24
25
26
27
28
29
# File 'lib/miq_automation_engine/service_models/miq_ae_service_generic_object.rb', line 24

def method_missing(method_name, *args)
  ae_user_identity unless @ae_user
  args = convert_params_to_ar_model(args)
  results = object_send(method_name, *args)
  wrap_results(results)
end

Instance Method Details

#add_to_service(service) ⇒ Object

Raises:

  • (ArgumentError)

5
6
7
8
9
# File 'lib/miq_automation_engine/service_models/miq_ae_service_generic_object.rb', line 5

def add_to_service(service)
  error_msg = "service must be a MiqAeServiceService"
  raise ArgumentError, error_msg unless service.kind_of?(MiqAeMethodService::MiqAeServiceService)
  ar_method { wrap_results(Service.find_by_id(service.id).add_resource!(@object)) }
end

#remove_from_service(service) ⇒ Object

Raises:

  • (ArgumentError)

11
12
13
14
15
# File 'lib/miq_automation_engine/service_models/miq_ae_service_generic_object.rb', line 11

def remove_from_service(service)
  error_msg = "service must be a MiqAeServiceService"
  raise ArgumentError, error_msg unless service.kind_of?(MiqAeMethodService::MiqAeServiceService)
  ar_method { wrap_results(Service.find_by_id(service.id).remove_resource(@object)) }
end