Module: Safetynet::ClassMethods
- Defined in:
- lib/safetynet.rb
Instance Method Summary collapse
-
#safetynet(channel, filters = {}, options = {}) ⇒ Object
safetynet channel email|sms (symbol) filters Hash of method names to watch (email only) that fits after_action requirements options = { email: { Hash for each channel (matches to field on User model) and includes: limit: 1, Maximum # of methods for this channel (default: 1) timeframe: 30.minutes Minimum allowed timeframe between last method and next (default: 30.minutes) } } Options merges Rails.configuration.safetynet before any class-specific options.
-
#safetynet_channel ⇒ Object
Accessed in instance methods by calling self.class.safetynet_channel.
-
#safetynet_options ⇒ Object
Accessed in instance methods by calling self.class.safetynet_options.
Instance Method Details
#safetynet(channel, filters = {}, options = {}) ⇒ Object
safetynet
channel email|sms (symbol)
filters Hash of method names to watch (email only) that fits after_action requirements
options = {
email: { Hash for each channel (matches to field on User model) and includes:
limit: 1, Maximum # of methods for this channel (default: 1)
timeframe: 30.minutes Minimum allowed timeframe between last method and next (default: 30.minutes)
}
}
Options merges Rails.configuration.safetynet before any class-specific options
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/safetynet.rb', line 124 def safetynet(channel, filters={}, ={}) @safetynet_channel = channel @safetynet_options = { whitelist: /@example.com/, email: { limit: 1, timeframe: 30.minutes } }.merge(Rails.configuration.safetynet).merge() # If class is a rails mailer, add after_action hook if (self.ancestors & [ActionMailer::Base]).any? if filters.empty? after_action :check_safetynet_window else after_action :check_safetynet_window, filters end end end |
#safetynet_channel ⇒ Object
Accessed in instance methods by calling self.class.safetynet_channel
144 145 146 |
# File 'lib/safetynet.rb', line 144 def safetynet_channel @safetynet_channel end |
#safetynet_options ⇒ Object
Accessed in instance methods by calling self.class.safetynet_options
148 149 150 |
# File 'lib/safetynet.rb', line 148 def @safetynet_options end |