Module: Context::TestCase
- Defined in:
- lib/context/core.rb,
lib/context/lifecycle.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#run_all_callbacks(callback_type) ⇒ Object
:nodoc:.
-
#run_each_callbacks(callback_type) ⇒ Object
:nodoc:.
-
#set_values_from_callbacks(values) ⇒ Object
:nodoc:.
Instance Method Details
#run_all_callbacks(callback_type) ⇒ Object
:nodoc:
82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/context/lifecycle.rb', line 82 def run_all_callbacks(callback_type) # :nodoc: previous_ivars = instance_variables self.class.gather_callbacks(callback_type, :all).each { |c| instance_eval(&c) if c } (instance_variables - previous_ivars).inject({}) do |hash, ivar| hash.update ivar => instance_variable_get(ivar) end rescue Object => exception raise <<-BANG Error running the #{callback_type}(:all) callback for #{name} #{exception.class.name}: #{exception.} #{exception.backtrace.join("\n")} BANG end |
#run_each_callbacks(callback_type) ⇒ Object
:nodoc:
75 76 77 78 79 80 |
# File 'lib/context/lifecycle.rb', line 75 def run_each_callbacks(callback_type) # :nodoc: self.class.gather_callbacks(callback_type, :each).each do |c| next if !c c.is_a?(Proc) ? instance_eval(&c) : send(c) end end |
#set_values_from_callbacks(values) ⇒ Object
:nodoc:
96 97 98 99 100 |
# File 'lib/context/lifecycle.rb', line 96 def set_values_from_callbacks(values) # :nodoc: values.each do |name, value| instance_variable_set name, value end end |