Sha256: 6ab0ea7dff5ebedb5579e6564b0fc583648f8f83854e4408d4f6bcec2b960155

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

Contents

require 'pusher'

module ActsAsNotifiableRedmine
  module Couriers

    class PusherCourier

      class << self
        def def_field(*names)
          class_eval do
            names.each do |name|
              define_method(name) do |*args|
                args.empty? ? instance_variable_get("@#{name}") : instance_variable_set("@#{name}", *args)
              end
            end
          end
        end
      end

      def_field :name, :app_id, :key, :secret, :encrypted


      def initialize(&block)
        @name      = 'Pusher'
        @app_id    = ''
        @key       = ''
        @secret    = ''
        @encrypted = true

        instance_eval(&block)
        setup_pusher
      end


      def send_notification(channels, event, options)
        Pusher.trigger(channels, event, options)
      end


      private


      def setup_pusher
        Pusher.app_id    = @app_id
        Pusher.key       = @key
        Pusher.secret    = @secret
        Pusher.encrypted = @encrypted
      end

    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
acts_as_notifiable_redmine-0.1.1 lib/acts_as_notifiable_redmine/couriers/pusher_courier.rb