Module: Callbacks::InstanceMethods

Defined in:
lib/instancemethods.rb

Instance Method Summary collapse

Instance Method Details

#callback_actions(show_classvars = true) ⇒ Object



4
5
6
7
8
# File 'lib/instancemethods.rb', line 4

def callback_actions(show_classvars = true)
  return self.class_callback_actions
  #return self.instance_callbacks if show_classvars == false
  #return self.class_callback_actions + self.instance_callback_actions if show_classvars == true
end

#callback_actions_for(method, type) ⇒ Object

Really don’t know what this does :p But it works! I’m really, really bad at metaprogramming



12
13
14
15
16
17
18
19
# File 'lib/instancemethods.rb', line 12

def callback_actions_for(method, type)
  begin
    return self.callback_actions[method] if type.nil?
    return self.callback_actions[method][type] ||= []
  rescue NoMethodError
    return []
  end
end

#class_callback_actionsObject



21
22
23
# File 'lib/instancemethods.rb', line 21

def class_callback_actions
  self.class.callback_actions
end

#trigger_callback_actions(method, type) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/instancemethods.rb', line 25

def trigger_callback_actions(method, type)
  
  self.callback_actions_for(method, type).each do |callback|
    if callback.block
      return instance_eval(&callback.block)
    else
      callback.proc.call
    end
  end

  #Should I return something?
end