Class: ActivityNotification::OptionalTarget::Base
- Inherits:
-
Object
- Object
- ActivityNotification::OptionalTarget::Base
- Defined in:
- lib/activity_notification/optional_targets/base.rb
Overview
Abstract optional target class to develop optional notification target class.
Instance Attribute Summary collapse
-
#view_context ⇒ Object
View context to render notification message.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Base
constructor
Initialize method to create view context in this OptionalTarget instance.
-
#initialize_target(_options = {}) ⇒ Object
Initialize method to be overriden in user implementation class.
-
#notify(_notification, _options = {}) ⇒ Object
Publishing notification method to be overriden in user implementation class.
-
#to_optional_target_name ⇒ Object
Returns demodulized symbol class name as optional target name.
Constructor Details
#initialize(options = {}) ⇒ Base
Initialize method to create view context in this OptionalTarget instance
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/activity_notification/optional_targets/base.rb', line 14 def initialize( = {}) @view_context = ActionView::Base.new(ActionController::Base.view_paths, {}) @view_context.class_eval do include Rails.application.routes.url_helpers def ActionMailer::Base. end end initialize_target() unless .delete(:skip_initializing_target) end |
Instance Attribute Details
#view_context ⇒ Object
View context to render notification message
8 9 10 |
# File 'lib/activity_notification/optional_targets/base.rb', line 8 def view_context @view_context end |
Instance Method Details
#initialize_target(_options = {}) ⇒ Object
Initialize method to be overriden in user implementation class
33 34 35 |
# File 'lib/activity_notification/optional_targets/base.rb', line 33 def initialize_target( = {}) raise NotImplementedError, "You have to implement #{self.class}##{__method__}" end |
#notify(_notification, _options = {}) ⇒ Object
Publishing notification method to be overriden in user implementation class
40 41 42 |
# File 'lib/activity_notification/optional_targets/base.rb', line 40 def notify(_notification, = {}) raise NotImplementedError, "You have to implement #{self.class}##{__method__}" end |
#to_optional_target_name ⇒ Object
Returns demodulized symbol class name as optional target name
27 28 29 |
# File 'lib/activity_notification/optional_targets/base.rb', line 27 def to_optional_target_name self.class.name.demodulize.underscore.to_sym end |