lib/micro/observers/events_or_actions.rb in u-observers-0.4.0 vs lib/micro/observers/events_or_actions.rb in u-observers-0.5.0

- old
+ new

@@ -2,18 +2,24 @@ module Micro module Observers module EventsOrActions - DEFAULT = [:call] + DEFAULTS = [:call] - def self.[](values) - vals = Utils.compact_array(values) + def self.[](value) + values = Utils.compact_array(value) - vals.empty? ? DEFAULT : vals + values.empty? ? DEFAULTS : values end - private_constant :DEFAULT + def self.fetch_actions(hash) + return self[hash.fetch(:actions) { hash.fetch(:action) }] if hash.is_a?(Hash) + + raise ArgumentError, 'expected a hash with the key :action or :actions' + end + + private_constant :DEFAULTS end end end