Class: Proof::Extend
- Inherits:
-
Object
- Object
- Proof::Extend
- Includes:
- Initializer
- Defined in:
- lib/proof/extend.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.into(obj_under_test) ⇒ Object
7 8 9 10 |
# File 'lib/proof/extend.rb', line 7 def self.into(obj_under_test) instance = new obj_under_test instance.extend_obj end |
Instance Method Details
#defined ⇒ Object
37 38 39 |
# File 'lib/proof/extend.rb', line 37 def defined @defined ||= mod.const_defined? :Proof, search_ancestors=false end |
#extend_obj ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/proof/extend.rb', line 16 def extend_obj if extension.nil? Output.details "#{mod.name} not extended by #{extension_name}" return obj_under_test end Output.details "Extending #{extension_name} into #{mod.name}" Extension.! obj_under_test, extension end |
#extension ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/proof/extend.rb', line 26 def extension return @extension if @extension Output.details "#{mod.name} has #{defined ? '' : 'no '}inner Proof" return nil unless defined Output.details "Getting constant #{mod.name}::Proof" @extension ||= mod.const_get :Proof, search_ancestors=false end |
#extension_name ⇒ Object
41 42 43 |
# File 'lib/proof/extend.rb', line 41 def extension_name "#{mod.name}::Proof" end |
#mod ⇒ Object
12 13 14 |
# File 'lib/proof/extend.rb', line 12 def mod @mod ||= ([Module, Class].include?(obj_under_test.class) ? obj_under_test : obj_under_test.class) end |