mailboxer 0.2.5 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/README.rdoc CHANGED
@@ -27,6 +27,7 @@ And don't forget to migrate you database:
27
27
 
28
28
  = Requirements
29
29
 
30
+ OUTDATED - It will be documented in the next days
30
31
  We are now adding support for sending emails when a Notification or a Message is sent to one o more recipients. So that, we mus assure that Messageable models have some specific methods. This methods are:
31
32
 
32
33
  #Returning any kind of indentification you want for the model
@@ -45,7 +46,7 @@ We are now adding support for sending emails when a Notification or a Message is
45
46
  end
46
47
 
47
48
  If these methods are not present, default ones will be created (the ones above).
48
-
49
+ /OUTDATED
49
50
 
50
51
  = Usage
51
52
 
@@ -29,7 +29,7 @@ class Message < Notification
29
29
  msg_receipt.mailbox_type = "inbox"
30
30
  temp_receipts << msg_receipt
31
31
  #Should send an email?
32
- if Mailboxer.uses_emails and r.should_email? self
32
+ if Mailboxer.uses_emails and r.send(Mailboxer.should_email_method,self)
33
33
  MessageMailer.send_email(self,r).deliver
34
34
  end
35
35
  end
@@ -43,7 +43,7 @@ class Notification < ActiveRecord::Base
43
43
  msg_receipt.receiver = r
44
44
  temp_receipts << msg_receipt
45
45
  #Should send an email?
46
- if Mailboxer.uses_emails and r.should_email? self
46
+ if Mailboxer.uses_emails and r.send(Mailboxer.should_email_method,self)
47
47
  NotificationMailer.send_email(self,r).deliver
48
48
  end
49
49
  end
@@ -5,4 +5,9 @@ Mailboxer.setup do |config|
5
5
 
6
6
  #Configures the default from for the email sent for Messages and Notifications of Mailboxer
7
7
  config.default_from = "no-reply@mailboxer.com"
8
+
9
+ #Configures the methods needed by mailboxer
10
+ #config.email_method = :email
11
+ #config.name_method = :name
12
+ #config.should_email_method = :should_email?
8
13
  end
data/lib/mailboxer.rb CHANGED
@@ -2,12 +2,15 @@ module Mailboxer
2
2
  module Models
3
3
  autoload :Messageable, 'mailboxer/models/messageable'
4
4
  end
5
- module Exceptions
6
- autoload :NotCompliantModel, 'mailboxer/exceptions'
7
- end
8
5
 
9
6
  mattr_accessor :default_from
10
7
  mattr_accessor :uses_emails
8
+ mattr_accessor :email_method
9
+ @@email_method = :email
10
+ mattr_accessor :name_method
11
+ @@name_method = :name
12
+ mattr_accessor :should_email_method
13
+ @@should_email_method = :should_email?
11
14
 
12
15
  class << self
13
16
  def setup
@@ -16,28 +16,29 @@ module Mailboxer
16
16
  end
17
17
  end
18
18
 
19
- module InstanceMethods
20
- #Returning any kind of indentification you want for the model
21
- def name
22
- super
23
- rescue NameError
24
- return "You should add method :name in your Messageable model"
25
- end
19
+ module InstanceMethods
20
+ eval <<-EOM
21
+ #Returning any kind of indentification you want for the model
22
+ def #{Mailboxer.name_method}
23
+ super
24
+ rescue NameError
25
+ return "You should add method :name in your Messageable model"
26
+ end
26
27
 
27
- #Returning the email address of the model
28
- def email
29
- super
30
- rescue NameError
31
- return "define_email@on_your.model"
32
- end
33
-
34
- #Returning whether an email should be sent for this object (Message or Notification)
35
- def should_email?(object)
36
- super
37
- rescue NameError
38
- return true
39
- end
28
+ #Returning the email address of the model
29
+ def #{Mailboxer.email_method}
30
+ super
31
+ rescue NameError
32
+ return "define_email@on_your.model"
33
+ end
40
34
 
35
+ #Returning whether an email should be sent for this object (Message or Notification)
36
+ def #{Mailboxer.should_email_method}(object)
37
+ super
38
+ rescue NameError
39
+ return true
40
+ end
41
+ EOM
41
42
  #Gets the mailbox of the messageable
42
43
  def mailbox
43
44
  @mailbox = Mailbox.new(self) if @mailbox.nil?
@@ -139,8 +140,7 @@ module Mailboxer
139
140
  return nil
140
141
  end
141
142
  end
142
-
143
-
143
+
144
144
  #Mark the object as trashed for messageable.
145
145
  #
146
146
  #Object can be:
data/mailboxer.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "mailboxer"
3
- s.version = "0.2.5"
3
+ s.version = "0.3.0"
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." +
@@ -5,4 +5,9 @@ Mailboxer.setup do |config|
5
5
 
6
6
  #Configures the default from for the email sent for Messages and Notifications of Mailboxer
7
7
  config.default_from = "no-reply@mailboxer.com"
8
+
9
+ #Configures the methods needed by mailboxer
10
+ #config.email_method = :email
11
+ #config.name_method = :name
12
+ #config.should_email_method = :should_email?
8
13
  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:
6
6
  segments:
7
7
  - 0
8
- - 2
9
- - 5
10
- version: 0.2.5
8
+ - 3
9
+ - 0
10
+ version: 0.3.0
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-07-08 00:00:00 +02:00
18
+ date: 2011-07-12 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -156,6 +156,7 @@ extra_rdoc_files: []
156
156
 
157
157
  files:
158
158
  - .gitignore
159
+ - .rspec
159
160
  - .yardopts
160
161
  - Gemfile
161
162
  - LICENSE.txt
@@ -180,7 +181,6 @@ files:
180
181
  - lib/generators/mailboxer/templates/migration.rb
181
182
  - lib/mailboxer.rb
182
183
  - lib/mailboxer/engine.rb
183
- - lib/mailboxer/exceptions.rb
184
184
  - lib/mailboxer/models/messageable.rb
185
185
  - mailboxer.gemspec
186
186
  - spec/dummy/Gemfile
@@ -1,12 +0,0 @@
1
- module Mailboxer
2
- module Exceptions
3
- #Mailboxer::Exceptions::NotCompliantModel is raised when your model with acts_as_messageable
4
- #method is not compliant with the requirements for acting as messageable.
5
- #
6
- #These requirements are:
7
- #* <b>"name" method</b>: Returning any kind of indentification you want for the model
8
- #* <b>"email" method</b>: Returning the email address of the model.
9
- #* <b>"should_email?(object)" method</b>: Returning whether an email should be sent for this object (Message or Notification)
10
- class NotCompliantModel < RuntimeError; end
11
- end
12
- end