-
-
Save ngpestelos/6372228 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# How Clearance / Hoptoad does it | |
module Clearance | |
class << self | |
attr_accessor :configuration | |
end | |
def self.configure | |
self.configuration ||= Configuration.new | |
yield(configuration) | |
end | |
class Configuration | |
attr_accessor :mailer_sender | |
def initialize | |
@mailer_sender = '[email protected]' | |
end | |
end | |
end | |
# to use | |
Clearance.configure do |config| | |
config.mailer_sender = '[email protected]' | |
end | |
# How Devise does it | |
module Devise | |
mattr_accessor :mailer_sender # requires active support | |
@@mailer_sender = '[email protected]' | |
class << self | |
def setup | |
yield self | |
end | |
end | |
end | |
# to use | |
Devise.setup do |config| | |
config.mailer_sender = '[email protected]' | |
end | |
# references: http://robots.thoughtbot.com/post/344833329/mygem-configure-block |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment