Slotted constructor cleanup
This commit is contained in:
@ -2,7 +2,7 @@ module SlotMachine
|
||||
|
||||
class Slotted
|
||||
|
||||
def self.for(object , slots)
|
||||
def self.for(object , slots = nil)
|
||||
case object
|
||||
when :message
|
||||
SlottedMessage.new(slots)
|
||||
@ -19,11 +19,11 @@ module SlotMachine
|
||||
# previous object
|
||||
attr_reader :slots
|
||||
|
||||
def initialize( slots )
|
||||
raise "No slots #{object}" unless slots
|
||||
slots = [slots] unless slots.is_a?(Array)
|
||||
def initialize( slots = nil )
|
||||
return unless slots
|
||||
raise "stopped" unless slots.is_a?(Array)
|
||||
first = slots.shift
|
||||
return unless first
|
||||
raise "ended" unless first
|
||||
@slots = Slot.new(first)
|
||||
until(slots.empty?)
|
||||
@slots.set_next( Slot.new( slots.shift ))
|
||||
|
@ -6,6 +6,10 @@ module SlotMachine
|
||||
end
|
||||
alias :known_object :known_name
|
||||
|
||||
def initialize(slots)
|
||||
super(slots)
|
||||
raise "Message must have slots, but none given" unless slots
|
||||
end
|
||||
# load the slots into a register
|
||||
# the code is added to compiler
|
||||
# the register returned
|
||||
|
Reference in New Issue
Block a user