Sha256: 34991522fc7d17bed2fc7936bdf88f34388232b37c67517193977f50f60d2c5a

Contents?: true

Size: 557 Bytes

Versions: 8

Compression:

Stored size: 557 Bytes

Contents

module Emites
  module Resources
    module Hooks

      def notify(*hooked_methods)
        apply_hooks(hooked_methods.flatten)
      end

      private

      def apply_hooks(hooked_methods)
        hooked_methods.each do |method|
          alias_method "#{method}_without_notifier", method

          define_method method do |*args|
            result = send("#{method}_without_notifier", *args)
            publish("emites.#{base_klass.downcase}.#{method}", result, args.flatten)
            result
          end
        end
      end

    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
emites-client-0.1.4 lib/emites/resources/hooks.rb
emites-client-0.1.3 lib/emites/resources/hooks.rb
emites-client-0.1.2 lib/emites/resources/hooks.rb
emites-client-0.1.1 lib/emites/resources/hooks.rb
emites-client-0.1.0 lib/emites/resources/hooks.rb
emites-client-0.0.4 lib/emites/resources/hooks.rb
emites-client-0.0.3 lib/emites/resources/hooks.rb
emites-client-0.0.2 lib/emites/resources/hooks.rb