Sha256: 16fa8e281297e96be8e7c008a8e0bb021860df9ae88e76def8732bcea06642c8
Contents?: true
Size: 1.06 KB
Versions: 3
Compression:
Stored size: 1.06 KB
Contents
module Controll::Flow module EventMapper class Util attr_reader :event_map, :event NoMappingFoundError = Controll::Flow::NoMappingFoundError def initialize event, event_map @event ||= normalize event unless valid_map? event_map raise ArgumentError, "Invalid redirect map: #{event_map}, must be a non-empty Hash" end @event_map ||= event_map end # An event can also be a Symbol, # in which case it is a :notice event def map_event event_map.each do |path, events| return path.to_s if valid? events end raise NoMappingFoundError, "No path could be found for event: #{event.inspect} in map: #{event_map}" end protected include Controll::Event::Helper def valid_map? event_map event_map.kind_of?(Hash) && !event_map.blank? end def valid? events matcher.match?(events) end def matcher @matcher ||= Controll::Event::Matcher.new event end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
controll-0.3.2 | lib/controll/flow/event_mapper/util.rb |
controll-0.3.1 | lib/controll/flow/event_mapper/util.rb |
controll-0.3.0 | lib/controll/flow/event_mapper/util.rb |