Sha256: 5fbae2f8c494edd6ba2289120348de74165275b6136a549c8d52dff7217b73a0

Contents?: true

Size: 566 Bytes

Versions: 36

Compression:

Stored size: 566 Bytes

Contents

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

    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
billimatic-client-1.0.1 lib/billimatic/resources/hooks.rb
billimatic-client-1.0.0 lib/billimatic/resources/hooks.rb
billimatic-client-0.22.1 lib/billimatic/resources/hooks.rb
billimatic-client-0.22.0 lib/billimatic/resources/hooks.rb
billimatic-client-0.21.0 lib/billimatic/resources/hooks.rb
billimatic-client-0.20.0 lib/billimatic/resources/hooks.rb
billimatic-client-0.19.1 lib/billimatic/resources/hooks.rb
billimatic-client-0.19.0 lib/billimatic/resources/hooks.rb
billimatic-client-0.18.1 lib/billimatic/resources/hooks.rb
billimatic-client-0.18.0 lib/billimatic/resources/hooks.rb
billimatic-client-0.17.0 lib/billimatic/resources/hooks.rb
billimatic-client-0.16.0 lib/billimatic/resources/hooks.rb
billimatic-client-0.15.0 lib/billimatic/resources/hooks.rb
billimatic-client-0.14.1 lib/billimatic/resources/hooks.rb
billimatic-client-0.14.0 lib/billimatic/resources/hooks.rb
billimatic-client-0.13.0 lib/billimatic/resources/hooks.rb
billimatic-client-0.12.0 lib/billimatic/resources/hooks.rb
billimatic-client-0.11.3 lib/billimatic/resources/hooks.rb
billimatic-client-0.11.2 lib/billimatic/resources/hooks.rb
billimatic-client-0.11.1 lib/billimatic/resources/hooks.rb