Class: PatternMatchingExample

Inherits:
Object
  • Object
show all
Includes:
Contracts::Core
Defined in:
lib/contracts-ruby2/spec/fixtures/fixtures.rb,
lib/contracts-ruby3/spec/fixtures/fixtures.rb

Overview

pattern matching example with possible deep contract violation

Defined Under Namespace

Classes: Failure, StringWithHello, Success

Constant Summary collapse

Response =

Instance Method Summary collapse

Methods included from Contracts::Core

common, extended, included

Instance Method Details

#decorated_request(request) ⇒ Object



498
499
500
# File 'lib/contracts-ruby2/spec/fixtures/fixtures.rb', line 498

def decorated_request(request)
  request + "!"
end

#do_stuff(number, string, other_number) ⇒ Object



503
504
505
# File 'lib/contracts-ruby2/spec/fixtures/fixtures.rb', line 503

def do_stuff(number, string)
  "foo"
end

#double(x) ⇒ Object



513
514
515
# File 'lib/contracts-ruby2/spec/fixtures/fixtures.rb', line 513

def double x
  "bad"
end

#process_request(status) ⇒ Object



488
489
490
# File 'lib/contracts-ruby2/spec/fixtures/fixtures.rb', line 488

def process_request(status)
  Success.new(decorated_request(status.request))
end