Module: Tins::AskAndSend

Included in:
Object
Defined in:
lib/tins/ask_and_send.rb

Instance Method Summary collapse

Instance Method Details

#ask_and_send(method_name, *args, &block) ⇒ Object



3
4
5
6
7
# File 'lib/tins/ask_and_send.rb', line 3

def ask_and_send(method_name, *args, &block)
  if respond_to?(method_name)
    __send__(method_name, *args, &block)
  end
end

#ask_and_send!(method_name, *args, &block) ⇒ Object



9
10
11
12
13
# File 'lib/tins/ask_and_send.rb', line 9

def ask_and_send!(method_name, *args, &block)
  if respond_to?(method_name, true)
    __send__(method_name, *args, &block)
  end
end

#ask_and_send_or_self(method_name, *args, &block) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/tins/ask_and_send.rb', line 15

def ask_and_send_or_self(method_name, *args, &block)
  if respond_to?(method_name)
    __send__(method_name, *args, &block)
  else
    self
  end
end

#ask_and_send_or_self!(method_name, *args, &block) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/tins/ask_and_send.rb', line 23

def ask_and_send_or_self!(method_name, *args, &block)
  if respond_to?(method_name, true)
    __send__(method_name, *args, &block)
  else
    self
  end
end