Class: Gimme::GivesClassMethods
- Inherits:
-
BlankSlate
- Object
- BlankSlate
- Gimme::GivesClassMethods
- Defined in:
- lib/gimme/gives_class_methods.rb
Instance Attribute Summary collapse
-
#raises_no_method_error ⇒ Object
Returns the value of attribute raises_no_method_error.
Instance Method Summary collapse
-
#initialize(cls) ⇒ GivesClassMethods
constructor
A new instance of GivesClassMethods.
- #method_missing(method, *args, &block) ⇒ Object
Constructor Details
#initialize(cls) ⇒ GivesClassMethods
Returns a new instance of GivesClassMethods.
5 6 7 8 |
# File 'lib/gimme/gives_class_methods.rb', line 5 def initialize(cls) @cls = cls @raises_no_method_error = true end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/gimme/gives_class_methods.rb', line 10 def method_missing(method, *args, &block) cls = @cls = (class << cls; self; end) method = ResolvesMethods.new(,method,args).resolve(@raises_no_method_error) Gimme.class_methods.set(cls, method) Gimme.stubbings.set(cls, method, args, block) #TODO this will be redundantly overwritten .instance_eval do define_method method do |*actual_args| Gimme.invocations.increment(cls, method, actual_args) InvokesSatisfiedStubbing.new(cls).invoke(method, actual_args) end end EnsuresClassMethodRestoration.new(@cls).ensure(method) end |
Instance Attribute Details
#raises_no_method_error ⇒ Object
Returns the value of attribute raises_no_method_error.
4 5 6 |
# File 'lib/gimme/gives_class_methods.rb', line 4 def raises_no_method_error @raises_no_method_error end |