mailboxer 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.4
@@ -1,8 +1,8 @@
1
1
  class Notification < ActiveRecord::Base
2
2
 
3
3
  attr_accessor :recipients
4
- attr_accessor :object
5
4
  belongs_to :sender, :polymorphic => :true
5
+ belongs_to :object, :polymorphic => :true
6
6
  validates_presence_of :subject, :body
7
7
  has_many :receipts
8
8
 
@@ -12,10 +12,11 @@ class Notification < ActiveRecord::Base
12
12
 
13
13
  class << self
14
14
  #Sends a Notification to all the recipients
15
- def notify_all(recipients,subject,body)
15
+ def notify_all(recipients,subject,body,object = nil)
16
16
  notification = Notification.new({:body => body, :subject => subject})
17
17
  notification.recipients = recipients.is_a?(Array) ? recipients : [recipients]
18
18
  notification.recipients = notification.recipients.uniq
19
+ notification.object = object if object.present?
19
20
  return notification.deliver
20
21
  end
21
22
  end
@@ -24,6 +24,7 @@ class CreateMailboxer < ActiveRecord::Migration
24
24
  t.column :body, :text
25
25
  t.column :subject, :string, :default => ""
26
26
  t.references :sender, :polymorphic => true
27
+ t.references :object, :polymorphic => true
27
28
  t.column :conversation_id, :integer
28
29
  t.column :draft, :boolean, :default => false
29
30
  t.column :updated_at, :datetime, :null => false
@@ -46,9 +46,10 @@ module Mailboxer
46
46
  end
47
47
 
48
48
  #Sends a notification to the messageable
49
- def notify(subject,body)
49
+ def notify(subject,body,object = nil)
50
50
  notification = Notification.new({:body => body, :subject => subject})
51
51
  notification.recipients = [self]
52
+ notification.object = object if object.present?
52
53
  return notification.deliver
53
54
  end
54
55
 
data/mailboxer.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "mailboxer"
3
- s.version = "0.1.3"
3
+ s.version = "0.1.4"
4
4
  s.authors = ["Eduardo Casanova Cuesta"]
5
5
  s.summary = "Messaging system for rails apps."
6
6
  s.description = "A Rails engine that allows any model to act as messageable, permitting it interchange messages with any other messageable model." +
@@ -24,6 +24,7 @@ class CreateMailboxer < ActiveRecord::Migration
24
24
  t.column :body, :text
25
25
  t.column :subject, :string, :default => ""
26
26
  t.references :sender, :polymorphic => true
27
+ t.references :object, :polymorphic => true
27
28
  t.column :conversation_id, :integer
28
29
  t.column :draft, :boolean, :default => false
29
30
  t.column :updated_at, :datetime, :null => false
@@ -0,0 +1,72 @@
1
+ # This file is auto-generated from the current state of the database. Instead
2
+ # of editing this file, please use the migrations feature of Active Record to
3
+ # incrementally modify your database, and then regenerate this schema definition.
4
+ #
5
+ # Note that this schema.rb definition is the authoritative source for your
6
+ # database schema. If you need to create the application database on another
7
+ # system, you should be using db:schema:load, not running all the migrations
8
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
10
+ #
11
+ # It's strongly recommended to check this file into your version control system.
12
+
13
+ ActiveRecord::Schema.define(:version => 20110511145103) do
14
+
15
+ create_table "conversations", :force => true do |t|
16
+ t.string "subject", :default => ""
17
+ t.datetime "created_at", :null => false
18
+ t.datetime "updated_at", :null => false
19
+ end
20
+
21
+ create_table "cylons", :force => true do |t|
22
+ t.string "name"
23
+ t.string "email"
24
+ t.datetime "created_at"
25
+ t.datetime "updated_at"
26
+ end
27
+
28
+ create_table "ducks", :force => true do |t|
29
+ t.string "name"
30
+ t.string "email"
31
+ t.datetime "created_at"
32
+ t.datetime "updated_at"
33
+ end
34
+
35
+ create_table "notifications", :force => true do |t|
36
+ t.string "type"
37
+ t.text "body"
38
+ t.string "subject", :default => ""
39
+ t.integer "sender_id"
40
+ t.string "sender_type"
41
+ t.integer "object_id"
42
+ t.string "object_type"
43
+ t.integer "conversation_id"
44
+ t.boolean "draft", :default => false
45
+ t.datetime "updated_at", :null => false
46
+ t.datetime "created_at", :null => false
47
+ end
48
+
49
+ add_index "notifications", ["conversation_id"], :name => "index_notifications_on_conversation_id"
50
+
51
+ create_table "receipts", :force => true do |t|
52
+ t.integer "receiver_id"
53
+ t.string "receiver_type"
54
+ t.integer "notification_id", :null => false
55
+ t.boolean "read", :default => false
56
+ t.boolean "trashed", :default => false
57
+ t.boolean "deleted", :default => false
58
+ t.string "mailbox_type", :limit => 25
59
+ t.datetime "created_at", :null => false
60
+ t.datetime "updated_at", :null => false
61
+ end
62
+
63
+ add_index "receipts", ["notification_id"], :name => "index_receipts_on_notification_id"
64
+
65
+ create_table "users", :force => true do |t|
66
+ t.string "name"
67
+ t.string "email"
68
+ t.datetime "created_at"
69
+ t.datetime "updated_at"
70
+ end
71
+
72
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mailboxer
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 3
10
- version: 0.1.3
9
+ - 4
10
+ version: 0.1.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Eduardo Casanova Cuesta
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-10 00:00:00 +02:00
18
+ date: 2011-05-11 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -210,7 +210,8 @@ files:
210
210
  - spec/dummy/db/migrate/20110228120600_create_users.rb
211
211
  - spec/dummy/db/migrate/20110306002940_create_ducks.rb
212
212
  - spec/dummy/db/migrate/20110306015107_create_cylons.rb
213
- - spec/dummy/db/migrate/20110429101611_create_mailboxer.rb
213
+ - spec/dummy/db/migrate/20110511145103_create_mailboxer.rb
214
+ - spec/dummy/db/schema.rb
214
215
  - spec/dummy/public/404.html
215
216
  - spec/dummy/public/422.html
216
217
  - spec/dummy/public/500.html