Module: Lite::Command::Utils

Defined in:
lib/lite/command/utils.rb

Class Method Summary collapse

Class Method Details

.call(object, argument) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/lite/command/utils.rb', line 19

def call(object, argument)
  if argument.is_a?(Symbol) || argument.is_a?(String)
    object.send(argument)
  elsif argument.is_a?(Proc)
    object.instance_eval(&argument)
  else
    argument
  end
end

.hook(object, method_name, *args) ⇒ Object



15
16
17
# File 'lib/lite/command/utils.rb', line 15

def hook(object, method_name, *args)
  try(object, method_name, *args, include_private: true)
end

.try(object, method_name, *args, include_private: false) ⇒ Object



9
10
11
12
13
# File 'lib/lite/command/utils.rb', line 9

def try(object, method_name, *args, include_private: false)
  return unless object.respond_to?(method_name, include_private)

  object.send(method_name, *args)
end