Module: Dynflow::Testing::Mimic
- Included in:
- DummyExecutionPlan, DummyPlannedAction, DummyStep, DummyWorld
- Defined in:
- lib/dynflow/testing/mimic.rb
Overview
when extended into Class or an_object it makes all instances of the class or the object mimic the supplied types. It does so by hooking into kind_of? method.
Instance Method Summary collapse
Instance Method Details
#mimic!(*types) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/dynflow/testing/mimic.rb', line 19 def mimic!(*types) define =-> _ do define_method :mimic_types do types end define_method :kind_of? do |type| types.any? { |t| t <= type } || super(type) end alias_method :is_a?, :kind_of? end if self.kind_of? ::Class self.class_eval &define else self.singleton_class.class_eval &define end self end |