Sha256: 5999014b0b5e657ebabbedf89112f1ce339bc528fadf278dc3c4d1218455b19a

Contents?: true

Size: 737 Bytes

Versions: 5

Compression:

Stored size: 737 Bytes

Contents

require 'yaml'

module NotifyOn
  class BulkConfig

    def initialize(options = {})
    end

    def self.load
      new.load
    end

    def load
      return unless File.exists?(config_file) && config
      config.each do |model_name, notification_name|
        notification_name.each do |name, notify_on_config|
          model_name.classify.constantize.class_eval do
            notify_on (notify_on_config['action'] || notify_on_config['when']),
                      notify_on_config.deep_symbolize_keys
          end
        end
      end
    end

    private

      def config_file
        Rails.root.join('config', 'notifications.yml').to_s
      end

      def config
        YAML.load_file(config_file)
      end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
notify_on-1.0.5 lib/notify_on/bulk_config.rb
notify_on-1.0.4 lib/notify_on/bulk_config.rb
notify_on-1.0.3 lib/notify_on/bulk_config.rb
notify_on-1.0.2 lib/notify_on/bulk_config.rb
notify_on-1.0.1 lib/notify_on/bulk_config.rb