class Fixturama::Changes::Chain::Actions
@private Keep arguments of a message chain along with the corresponding actions
Public Class Methods
new(*list)
click to toggle source
# File lib/fixturama/changes/chain/actions.rb 13 def initialize(*list) 14 list = [{ return: nil }] if list.empty? 15 16 @list = list.flatten.reverse.flat_map do |item| 17 action = build(item) 18 [action] * action.repeat 19 end 20 end
Public Instance Methods
next()
click to toggle source
# File lib/fixturama/changes/chain/actions.rb 7 def next 8 @list.count > 1 ? @list.pop : @list.first 9 end
Private Instance Methods
build(item)
click to toggle source
# File lib/fixturama/changes/chain/actions.rb 22 def build(item) 23 item = Hash(item).transform_keys(&:to_sym) 24 case item.slice(:return, :raise).keys 25 when %i[return] then ReturnAction.new(item) 26 when %i[raise] then RaiseAction.new(item) 27 else raise Fixturama::FixtureError.new("an action", item) 28 end 29 end