Class: LightService::Organizer::ClassMethods::VerifyCallMethodExists

Inherits:
Object
  • Object
show all
Defined in:
lib/light-service/organizer.rb

Overview

We need to make sure existing users will use ‘call` method name going forward. This should be removed eventually.

Class Method Summary collapse

Class Method Details

.call(klass, first_caller = '') ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/light-service/organizer.rb', line 33

def self.call(klass, first_caller = '')
  invoker_method = caller_method(first_caller)
  return if invoker_method == 'call'

  call_method_exists = klass.methods.include?(:call)
  return if call_method_exists

  warning_msg = "The <#{klass.name}> class is an organizer, " \
                "its entry method (the one that calls with & reduce) " \
                "should be named `call`. " \
                "Please use #{klass}.call going forward."
  ActiveSupport::Deprecation.warn(warning_msg)
end

.caller_method(first_caller) ⇒ Object



47
48
49
50
51
# File 'lib/light-service/organizer.rb', line 47

def self.caller_method(first_caller)
  return nil unless first_caller =~ /`(.*)'/

  Regexp.last_match[1]
end