Class: BareTypes::Reference

Inherits:
BaseType show all
Defined in:
lib/types.rb,
lib/generative_testing/monkey_patch.rb

Overview

Monkey patch every bare class to include make and create_input make - a factory to create a random variant of the bare class create_input - creates an input that could be used with Bare.Encode for this type

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, reference) ⇒ Reference

Returns a new instance of Reference.



106
107
108
109
110
111
112
113
# File 'lib/types.rb', line 106

def initialize(name, reference)
  @name = name
  @ref = reference
  @finalized = false
  unless reference.is_a?(BareTypes::BaseType)
    raise ReferenceException.new("Reference must be to bare types")
  end
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



93
94
95
# File 'lib/types.rb', line 93

def name
  @name
end

#refObject

Returns the value of attribute ref.



94
95
96
# File 'lib/types.rb', line 94

def ref
  @ref
end

Class Method Details

.make(depth, names) ⇒ Object



18
19
20
# File 'lib/generative_testing/monkey_patch.rb', line 18

def self.make(depth, names)
  self.ref.make(depth, names)
end

Instance Method Details

#==(other) ⇒ Object



102
103
104
# File 'lib/types.rb', line 102

def ==(other)
  other.is_a?(Reference) && @name == other.name && @ref == other.ref
end

#create_inputObject



14
15
16
# File 'lib/generative_testing/monkey_patch.rb', line 14

def create_input
  self.ref.create_input
end

#cycle_search(seen) ⇒ Object



96
97
98
99
100
# File 'lib/types.rb', line 96

def cycle_search(seen)
  seen.add(self)
  @ref.cycle_search(seen)
  seen.pop
end

#decode(msg) ⇒ Object



125
126
127
# File 'lib/types.rb', line 125

def decode(msg)
  @ref.decode(msg)
end

#encode(msg, buffer) ⇒ Object



121
122
123
# File 'lib/types.rb', line 121

def encode(msg, buffer)
  @ref.encode(msg, buffer)
end

#finalize_references(schema) ⇒ Object



115
116
117
118
119
# File 'lib/types.rb', line 115

def finalize_references(schema)
  return if @finalized
  @finalized = true
  self.ref.finalize_references(schema)
end

#to_schema(buffer) ⇒ Object



129
130
131
# File 'lib/types.rb', line 129

def to_schema(buffer)
  buffer << @name.to_s
end