Sha256: 7565e6d9002dad8e9c0a2d2fe2cd442f07826eb3e9b681495b666b5ad81a5b0f
Contents?: true
Size: 1.52 KB
Versions: 14
Compression:
Stored size: 1.52 KB
Contents
require 'active_support/dependencies' module Agilib module PushNotification module Model extend ActiveSupport::Concern def send_push_notification(message, data = {}, platforms = :all) @platforms = Hash.new @devices = self.devices.all @responses = Hash.new message = message[0,50] unless platforms.is_a? Array if platforms.to_sym == :all @platforms = Agilib::PushNotification.avaiable_platforms else @platforms[platforms] = Agilib::PushNotification.avaiable_platforms[platforms] end else platforms.each do |platform| @platforms[platform] = Agilib::PushNotification.avaiable_platforms[platform] if Agilib::PushNotification.avaiable_platforms.has_key?(platform) end end @devices.each do |device| if @platforms.has_key? device.platform.to_sym platform = @platforms[device.platform.to_sym] @responses[device.platform.to_sym] = platform.send_notification(message, data, device) end end return @responses end module ClassMethods def agilib_push_notification(options = {}) if Agilib.use_modules[:push_notification].present? include Agilib::PushNotification::Model has_many :devices, :class_name => "Agilib::Device" end end end end end end if defined? ActiveRecord ActiveRecord::Base.send :include, Agilib::PushNotification::Model end
Version data entries
14 entries across 14 versions & 1 rubygems