Class: Surrogate::PorcReflector
- Inherits:
-
Struct
- Object
- Struct
- Surrogate::PorcReflector
- Defined in:
- lib/surrogate/porc_reflector.rb
Overview
reflects on the Plain Old Ruby Class to give info about methods that are useful for the comparer
Instance Attribute Summary collapse
-
#actual ⇒ Object
Returns the value of attribute actual.
Instance Method Summary collapse
- #class_inherited_methods ⇒ Object
- #class_other_methods ⇒ Object
- #class_without_bodies ⇒ Object
- #instance_inherited_methods ⇒ Object
- #instance_other_methods ⇒ Object
- #instance_without_bodies ⇒ Object
- #methods ⇒ Object
Instance Attribute Details
#actual ⇒ Object
Returns the value of attribute actual
4 5 6 |
# File 'lib/surrogate/porc_reflector.rb', line 4 def actual @actual end |
Instance Method Details
#class_inherited_methods ⇒ Object
27 28 29 |
# File 'lib/surrogate/porc_reflector.rb', line 27 def class_inherited_methods Set.new actual.singleton_class.instance_methods - actual.singleton_class.instance_methods(false) end |
#class_other_methods ⇒ Object
31 32 33 |
# File 'lib/surrogate/porc_reflector.rb', line 31 def class_other_methods Set.new(actual.singleton_class.instance_methods) - class_inherited_methods end |
#class_without_bodies ⇒ Object
35 36 37 |
# File 'lib/surrogate/porc_reflector.rb', line 35 def class_without_bodies Set.new actual.methods.select { |name| actual.method(name).parameters.any? { |param| param.size == 1 } } end |
#instance_inherited_methods ⇒ Object
19 20 21 |
# File 'lib/surrogate/porc_reflector.rb', line 19 def instance_inherited_methods Set.new actual.instance_methods - actual.instance_methods(false) end |
#instance_other_methods ⇒ Object
23 24 25 |
# File 'lib/surrogate/porc_reflector.rb', line 23 def instance_other_methods Set.new(actual.instance_methods) - instance_inherited_methods end |
#instance_without_bodies ⇒ Object
39 40 41 |
# File 'lib/surrogate/porc_reflector.rb', line 39 def instance_without_bodies Set.new actual.instance_methods.select { |name| actual.instance_method(name).parameters.any? { |param| param.size == 1 } } end |
#methods ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/surrogate/porc_reflector.rb', line 5 def methods { instance: { inherited: instance_inherited_methods, other: instance_other_methods, without_bodies: instance_without_bodies, }, class: { inherited: class_inherited_methods, other: class_other_methods, without_bodies: class_without_bodies, }, } end |