actionmailer-with-request 0.1.0 → 0.1.1

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.0
1
+ 0.1.1
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{actionmailer-with-request}
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Simone Carletti"]
@@ -20,7 +20,9 @@ Gem::Specification.new do |s|
20
20
  "Rakefile",
21
21
  "VERSION",
22
22
  "actionmailer-with-request.gemspec",
23
- "init.rb",
23
+ "lib/action_mailer_with_request/controller_mixin.rb",
24
+ "lib/action_mailer_with_request/mailer_default_url_options.rb",
25
+ "lib/action_mailer_with_request/railtie.rb",
24
26
  "lib/actionmailer_with_request.rb"
25
27
  ]
26
28
  s.homepage = %q{http://github.com/weppos/actionmailer_with_request}
@@ -0,0 +1,15 @@
1
+ module ActionMailerWithRequest
2
+ module ControllerMixin
3
+
4
+ def self.included(base)
5
+ base.class_eval do
6
+ before_filter :store_request
7
+ end
8
+ end
9
+
10
+ def store_request
11
+ Thread.current[:request] = request
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,19 @@
1
+ module ActionMailerWithRequest
2
+ module MailerDefaultUrlOptions
3
+
4
+ def self.included(base)
5
+ base.class_eval do
6
+ def default_url_options_with_current_request
7
+ host = Thread.current[:request].try(:host)
8
+ port = Thread.current[:request].try(:port)
9
+ default = {}
10
+ default[:host] = host if host
11
+ default[:port] = port if port and port != 80
12
+ default_url_options_without_current_request.merge(default)
13
+ end
14
+ alias_method_chain :default_url_options, :current_request
15
+ end
16
+ end
17
+
18
+ end
19
+ end
@@ -0,0 +1,11 @@
1
+ module ActionMailerWithRequest
2
+ class Railtie < Rails::Railtie
3
+
4
+ initializer "action_mailer_with_request.default_url_options" do |app|
5
+ ActionController::Base.send :include, ActionMailerWithRequest::ControllerMixin
6
+ ActionMailer::Base.send :include, ActionMailerWithRequest::MailerDefaultUrlOptions
7
+
8
+ Rails.logger.info("** ActionMailerWithRequest: initialized properly") if defined?(Rails)
9
+ end
10
+ end
11
+ end
@@ -1,33 +1,4 @@
1
- module ActionMailerWithRequest
1
+ require 'action_mailer_with_request/controller_mixin'
2
+ require 'action_mailer_with_request/mailer_default_url_options'
2
3
 
3
- module ControllerMixin
4
-
5
- def self.included(base)
6
- base.class_eval do
7
- before_filter :store_request
8
- end
9
- end
10
-
11
- def store_request
12
- Thread.current[:request] = request
13
- end
14
-
15
- end
16
-
17
- module MailerDefaultUrlOptions
18
-
19
- def self.included(base)
20
- base.class_eval do
21
- def default_url_options_with_current_request
22
- host = Thread.current[:request].try(:host)
23
- port = Thread.current[:request].try(:port)
24
- default = {}
25
- default[:host] = host if host
26
- default[:port] = port if port and port != 80
27
- default_url_options_without_current_request.merge(default)
28
- end
29
- alias_method_chain :default_url_options, :current_request
30
- end
31
- end
32
- end
33
- end
4
+ require 'action_mailer_with_request/railtie'
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 0
9
- version: 0.1.0
8
+ - 1
9
+ version: 0.1.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Simone Carletti
@@ -32,7 +32,9 @@ files:
32
32
  - Rakefile
33
33
  - VERSION
34
34
  - actionmailer-with-request.gemspec
35
- - init.rb
35
+ - lib/action_mailer_with_request/controller_mixin.rb
36
+ - lib/action_mailer_with_request/mailer_default_url_options.rb
37
+ - lib/action_mailer_with_request/railtie.rb
36
38
  - lib/actionmailer_with_request.rb
37
39
  has_rdoc: true
38
40
  homepage: http://github.com/weppos/actionmailer_with_request
data/init.rb DELETED
@@ -1,6 +0,0 @@
1
- require 'actionmailer_with_request'
2
-
3
- ActionController::Base.send :include, ActionMailerWithRequest::ControllerMixin
4
- ActionMailer::Base.send :include, ActionMailerWithRequest::MailerDefaultUrlOptions
5
-
6
- Rails.logger.info("** ActionMailerWithRequest: initialized properly") if defined?(Rails)