Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 14 lines (13 sloc) 0.397 kb
d8c2d5f @Manfred Rename from Plastic to Bendy.
authored
1 module Bendy
830ae98 @Manfred Implement a simple mock object called Shape.
authored
2 module Shape
5d10a41 @Manfred Add support for defining the class of a shape.
authored
3 def shape(*args)
9ebdc68 @Manfred Always subclass so stubbed methods don't persist.
authored
4 klass = args[0].kind_of?(Class) ? Class.new(args.shift) : Class.new
1f879ab @Manfred Allow arguments to be passed to initialize.
authored
5 methods = args[-1].kind_of?(Hash) ? args.pop : {}
6 methods.each do |attribute, value|
7 proc = value.kind_of?(Proc) ? value : Proc.new { |*args| value }
a98d4e1 @Manfred Optimillisize the shape implementation.
authored
8 klass.send(:define_method, attribute, &proc)
830ae98 @Manfred Implement a simple mock object called Shape.
authored
9 end
1f879ab @Manfred Allow arguments to be passed to initialize.
authored
10 klass.new(*args)
830ae98 @Manfred Implement a simple mock object called Shape.
authored
11 end
12 end
1f879ab @Manfred Allow arguments to be passed to initialize.
authored
13 end
Something went wrong with that request. Please try again.