Skip to content

Commit

Permalink
feat(message contracts): dynamically mix in new and from_hash into Pa…
Browse files Browse the repository at this point in the history
…ct::Message
  • Loading branch information
bethesque committed Feb 16, 2018
1 parent 2e48892 commit c0c3ad5
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions lib/pact/consumer_contract/message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def as_json
}
end


def request
@request ||= Pact::Consumer::Request::Actual.from_hash(
path: '/',
Expand Down Expand Up @@ -115,8 +114,30 @@ def to_s
end
end

module Pact::Message
def self.new *args
Pact::ConsumerContract::Message.new(*args)
if Pact.const_defined?('Message') && Pact::Message.class == Module
module Pact
module Message
def self.new *args
Pact::ConsumerContract::Message.new(*args)
end

def self.from_hash *args
Pact::ConsumerContract::Message.from_hash(*args)
end
end
end
end

if Pact.const_defined?('Message') && Pact::Message.class == Class
module Pact
class Message
def self.new *args
Pact::ConsumerContract::Message.new(*args)
end

def self.from_hash *args
Pact::ConsumerContract::Message.from_hash(*args)
end
end
end
end

0 comments on commit c0c3ad5

Please sign in to comment.