Module: SanitizeEmail
- Extended by:
- Deprecation
- Defined in:
- lib/sanitize_email.rb,
lib/sanitize_email/bleach.rb,
lib/sanitize_email/config.rb,
lib/sanitize_email/engine.rb,
lib/sanitize_email/railtie.rb,
lib/sanitize_email/version.rb,
lib/sanitize_email/deprecation.rb,
lib/sanitize_email/test_helpers.rb,
lib/sanitize_email/rspec_matchers.rb
Overview
See www.seejohncode.com/2012/01/09/deprecating-methods-in-ruby/ require ‘facets/module/mattr’ # gives cattr
Defined Under Namespace
Modules: Deprecation, RspecMatchers, TestHelpers Classes: Bleach, Config, Engine, MissingBlockParameter, Railtie
Constant Summary collapse
- VERSION =
'1.0.7'
Class Attribute Summary collapse
-
.force_sanitize ⇒ Object
Returns the value of attribute force_sanitize.
Class Method Summary collapse
- .[](key) ⇒ Object
- .janitor(options, &block) ⇒ Object
-
.local_environments ⇒ Object
NOTE: Deprecated method We have to actually define because we can’t deprecate methods that are hooked up via method_missing.
- .method_missing(name, *args) ⇒ Object
-
.sanitary(config_options = {}, &block) ⇒ Object
Regardless of the Config settings of SanitizeEmail you can do a local override to send sanitary email in any environment.
-
.sanitized_recipients ⇒ Object
NOTE: Deprecated method We have to actually define because we can’t deprecate methods that are hooked up via method_missing.
-
.unsanitary(&block) ⇒ Object
Regardless of the Config settings of SanitizeEmail you can do a local override to force unsanitary email in any environment.
Methods included from Deprecation
deprecated, deprecated_alias, deprecation
Class Attribute Details
.force_sanitize ⇒ Object
Returns the value of attribute force_sanitize.
48 49 50 |
# File 'lib/sanitize_email.rb', line 48 def force_sanitize @force_sanitize end |
Class Method Details
.[](key) ⇒ Object
26 27 28 29 |
# File 'lib/sanitize_email.rb', line 26 def self.[](key) return nil unless key.respond_to?(:to_sym) SanitizeEmail::Config.config[key.to_sym] end |
.janitor(options, &block) ⇒ Object
93 94 95 96 97 98 99 |
# File 'lib/sanitize_email.rb', line 93 def self.janitor(, &block) raise MissingBlockParameter, "SanitizeEmail.janitor must be called with a block" unless block_given? original = SanitizeEmail.force_sanitize SanitizeEmail.force_sanitize = [:forcing] yield SanitizeEmail.force_sanitize = original end |
.local_environments ⇒ Object
NOTE: Deprecated method We have to actually define because we can’t deprecate methods that are hooked up via method_missing
43 44 45 |
# File 'lib/sanitize_email.rb', line 43 def self.local_environments SanitizeEmail[:local_environments] end |
.method_missing(name, *args) ⇒ Object
31 32 33 |
# File 'lib/sanitize_email.rb', line 31 def self.method_missing(name, *args) SanitizeEmail[name] end |
.sanitary(config_options = {}, &block) ⇒ Object
Regardless of the Config settings of SanitizeEmail you can do a local override to send sanitary email in any environment. You have access to all the same configuration options in the parameter hash as you can set in the actual SanitizeEmail.configure block.
SanitizeEmail.sanitary(=> ‘[email protected]’) do # these config options are merged with the globals
Mail.deliver do
from '[email protected]'
to '[email protected]' # Will actually be sent to the override addresses, in this case: [email protected]
reply_to '[email protected]'
subject 'subject'
end
end
65 66 67 68 69 70 71 72 73 |
# File 'lib/sanitize_email.rb', line 65 def self.sanitary( = {}, &block) raise MissingBlockParameter, "SanitizeEmail.sanitary must be called with a block" unless block_given? janitor({:forcing => true}) do original = SanitizeEmail::Config.config.dup SanitizeEmail::Config.config.merge!() yield SanitizeEmail::Config.config = original end end |
.sanitized_recipients ⇒ Object
NOTE: Deprecated method We have to actually define because we can’t deprecate methods that are hooked up via method_missing
37 38 39 |
# File 'lib/sanitize_email.rb', line 37 def self.sanitized_recipients SanitizeEmail[:sanitized_recipients] end |
.unsanitary(&block) ⇒ Object
Regardless of the Config settings of SanitizeEmail you can do a local override to force unsanitary email in any environment.
SanitizeEmail.unsanitary do
Mail.deliver do
from '[email protected]'
to '[email protected]'
reply_to '[email protected]'
subject 'subject'
end
end
86 87 88 89 90 91 |
# File 'lib/sanitize_email.rb', line 86 def self.unsanitary &block raise MissingBlockParameter, "SanitizeEmail.unsanitary must be called with a block" unless block_given? janitor({:forcing => false}) do yield end end |