class Transpec::RecordBuilder
This class is intended to be inherited to build complex record. The reasons why you should inherit this class rather than Record
are:
* You need to care about String and Symbol around Record#old_syntax and #new_syntax. * All record instances are kept in a Report until the end of Transpec process. This mean that if a custom record keeps a syntax object as an ivar, the AST kept by the syntax object won't be GCed.
Public Class Methods
build(*args)
click to toggle source
# File lib/transpec/record.rb, line 97 def self.build(*args) new(*args).build end
new(*params)
click to toggle source
# File lib/transpec/record.rb, line 115 def initialize(*params) @initializer_params = params end
param_names(*names)
click to toggle source
# File lib/transpec/record.rb, line 101 def self.param_names(*names) names.each_with_index do |name, index| define_method(name) do @initializer_params[index] end end end
Public Instance Methods
build()
click to toggle source
# File lib/transpec/record.rb, line 109 def build Record.new(old_syntax, new_syntax, { type: type, annotation: annotation }) end
Private Instance Methods
annotation()
click to toggle source
# File lib/transpec/record.rb, line 131 def annotation nil end
new_syntax()
click to toggle source
# File lib/transpec/record.rb, line 123 def new_syntax nil end
old_syntax()
click to toggle source
# File lib/transpec/record.rb, line 119 def old_syntax nil end
type()
click to toggle source
# File lib/transpec/record.rb, line 127 def type nil end