Module: ConvenientService::Core::Concern::InstanceMethods

Defined in:
lib/convenient_service/core/concern/instance_methods.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, **kwargs, &block) ⇒ void (private)

Note:

Config commitment via a missing instance method is very rare. It is only possible when an instance is created without calling ‘.new` on a class.

This method returns an undefined value.

Commits config. In other words, includes ‘concerns` into the mixing class. If `method` is still NOT defined, raises `NoMethodError`, otherwise - retries to call the `method`.

Parameters:

  • method (Symbol)
  • args (Array<Object>)
  • kwargs (Hash{Symbol => Object})
  • block (Proc, nil)


67
68
69
70
71
72
73
74
75
76
77
# File 'lib/convenient_service/core/concern/instance_methods.rb', line 67

def method_missing(method, *args, **kwargs, &block)
  self.class.commit_config!(trigger: Constants::Triggers::INSTANCE_METHOD_MISSING)

  return ::ConvenientService.reraise { super } unless Utils::Module.instance_method_defined?(self.class, method, public: true, protected: false, private: false)

  return ::ConvenientService.reraise { super } if self.class.middlewares(method, scope: :instance).defined_without_super_method?

  ConvenientService.logger.debug { "[Core] Committed config for `#{self.class}` | Triggered by `method_missing` | Method: `##{method}`" }

  __send__(method, *args, **kwargs, &block)
end

Instance Method Details

#initializevoid



13
14
# File 'lib/convenient_service/core/concern/instance_methods.rb', line 13

def initialize(...)
end