module BusinessCentral::Object::ObjectHelper

Public Instance Methods

navigation(object_name, *_params) click to toggle source
object(object_name, *_params) click to toggle source
# File lib/business_central/object/object_helper.rb, line 8
def object(object_name, *_params)
  define_method(object_name) do |argument = nil|
    object = "@#{object_name}_cache".to_sym
    if argument.nil?
      if !instance_variable_defined?(object)
        instance_variable_set(
          object,
          BusinessCentral::Object.const_get(
            object_name.to_s.to_camel_case(true).to_s.to_sym
          ).new(self, argument)
        )
      else
        instance_variable_get(object)
      end
    else
      instance_variable_set(
        object,
        BusinessCentral::Object.const_get(
          object_name.to_s.to_camel_case(true).to_s.to_sym
        ).new(self, argument)
      )
    end
  end
end