Sha256: 4a842283ff0901b0d1b1dd51c62751afb9fbfaba9cf22c8d9ccd723705234f01

Contents?: true

Size: 781 Bytes

Versions: 2

Compression:

Stored size: 781 Bytes

Contents

module Coupler
  module Extensions
    module Notifications
      include Models

      def self.registered(app)
        app.before do
          Notification.filter(~{:seen => true}, {:url => request.path_info}).update(:seen => true)
        end

        app.get "/notifications" do
          @notifications = Notification.order(:created_at).all
          erb :"notifications/index"
        end

        app.get "/notifications/unseen.json" do
          content_type 'application/json'
          notifications = Notification.filter(~{:seen => true}).order(:created_at).all
          notifications.collect do |n|
            { 'id' => n.id, 'message' => n.message, 'url' => n.url, 'created_at' => n.created_at.iso8601 }
          end.to_json
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
coupler-0.0.9-java lib/coupler/extensions/notifications.rb
coupler-0.0.8-java lib/coupler/extensions/notifications.rb