Sha256: aff546fef393c787ee85535846e629135323ddc6b3e5957f655fdb695f0cefd8

Contents?: true

Size: 559 Bytes

Versions: 66

Compression:

Stored size: 559 Bytes

Contents

module Cobrato
  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("cobrato.#{base_klass.downcase}.#{method}", result, args.flatten)
            result
          end
        end
      end

    end
  end
end

Version data entries

66 entries across 66 versions & 1 rubygems

Version Path
cobrato-client-0.23.0.beta8 lib/cobrato/resources/hooks.rb
cobrato-client-0.23.0.beta7 lib/cobrato/resources/hooks.rb
cobrato-client-0.23.0.beta6 lib/cobrato/resources/hooks.rb
cobrato-client-0.23.0.beta5 lib/cobrato/resources/hooks.rb
cobrato-client-0.23.0.beta4 lib/cobrato/resources/hooks.rb
cobrato-client-0.23.0.beta3 lib/cobrato/resources/hooks.rb
cobrato-client-0.23.0.beta2 lib/cobrato/resources/hooks.rb
cobrato-client-0.23.0.beta1 lib/cobrato/resources/hooks.rb
cobrato-client-0.22.0 lib/cobrato/resources/hooks.rb
cobrato-client-0.21.0 lib/cobrato/resources/hooks.rb
cobrato-client-0.20.0 lib/cobrato/resources/hooks.rb
cobrato-client-0.19.0 lib/cobrato/resources/hooks.rb
cobrato-client-0.18.0 lib/cobrato/resources/hooks.rb
cobrato-client-0.17.0 lib/cobrato/resources/hooks.rb
cobrato-client-0.16.0 lib/cobrato/resources/hooks.rb
cobrato-client-0.15.0 lib/cobrato/resources/hooks.rb
cobrato-client-0.14.0 lib/cobrato/resources/hooks.rb
cobrato-client-0.13.0 lib/cobrato/resources/hooks.rb
cobrato-client-0.12.0 lib/cobrato/resources/hooks.rb
cobrato-client-0.11.0 lib/cobrato/resources/hooks.rb