Module: Pact::Reification

Defined in:
lib/pact/reification.rb

Class Method Summary collapse

Class Method Details

.from_term(term) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/pact/reification.rb', line 6

def self.from_term(term)
  case
  when term.respond_to?(:generate)
    term.generate
  when term.is_a?(Hash)
    term.inject({}) do |mem, (key,term)|
      mem[key] = from_term(term)
    mem
    end
  when term.is_a?(Array)
    term.inject([]) do |mem, term|
      mem << from_term(term)
      mem
    end
  else
    term
  end
end