Sha256: 4a3a32dae1c9dfc4612611bb4d92eec9e83830be94a397ea39ba458302b8ea88

Contents?: true

Size: 1010 Bytes

Versions: 1

Compression:

Stored size: 1010 Bytes

Contents

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 lib/acts_as_notifiable_redmine/couriers/pusher_courier.rb