Class: Typedocs::MethodSpec::AnyOf
- Inherits:
-
Object
- Object
- Typedocs::MethodSpec::AnyOf
- Defined in:
- lib/typedocs/method_spec.rb
Instance Method Summary collapse
- #call_with_validate(method, *args, &block) ⇒ Object
-
#initialize(specs) ⇒ AnyOf
constructor
- MethodSpec::Single
-
->.
- #to_source ⇒ Object
Constructor Details
#initialize(specs) ⇒ AnyOf
- MethodSpec::Single
-
->
5 6 7 8 9 10 |
# File 'lib/typedocs/method_spec.rb', line 5 def initialize(specs) specs.each do|spec| Typedocs.ensure_klass(spec, Typedocs::MethodSpec::Single) end @specs = specs end |
Instance Method Details
#call_with_validate(method, *args, &block) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/typedocs/method_spec.rb', line 12 def call_with_validate(method, *args, &block) spec = nil @specs.each do|s| begin s.validate_caller(args, block) spec = s break rescue Typedocs::ArgumentError, Typedocs::BlockError end end unless spec raise Typedocs::ArgumentError, "Arguments not match any rule" end ret = method.call(*args, &block) spec.validate_retval ret ret end |
#to_source ⇒ Object
32 33 34 |
# File 'lib/typedocs/method_spec.rb', line 32 def to_source @specs.map(&:to_source).join(' || ') end |