OSDN Git Service

Notifiable concern
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Fri, 21 Jun 2013 20:17:41 +0000 (23:17 +0300)
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Fri, 21 Jun 2013 20:17:41 +0000 (23:17 +0300)
app/models/concerns/notifiable.rb [new file with mode: 0644]

diff --git a/app/models/concerns/notifiable.rb b/app/models/concerns/notifiable.rb
new file mode 100644 (file)
index 0000000..722f375
--- /dev/null
@@ -0,0 +1,15 @@
+# == Notifiable concern
+#
+# Contains notification functionality shared between UsersProject and UsersGroup
+#
+module Notifiable
+  extend ActiveSupport::Concern
+
+  included do
+    validates :notification_level, inclusion: { in: Notification.project_notification_levels }, presence: true
+  end
+
+  def notification
+    @notification ||= Notification.new(self)
+  end
+end