Class: ActiveNotify::CarrierDescriptor
- Inherits:
-
Object
- Object
- ActiveNotify::CarrierDescriptor
- Defined in:
- lib/active_notify/carrier_descriptor.rb
Constant Summary collapse
- RESERVED_KEYS =
%i[class_name if unless].freeze
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #args(context) ⇒ Object
- #constant ⇒ Object
- #deliver?(context) ⇒ Boolean
-
#initialize(name, notifier_class, options = {}) ⇒ CarrierDescriptor
constructor
A new instance of CarrierDescriptor.
Constructor Details
#initialize(name, notifier_class, options = {}) ⇒ CarrierDescriptor
Returns a new instance of CarrierDescriptor.
9 10 11 12 13 14 |
# File 'lib/active_notify/carrier_descriptor.rb', line 9 def initialize(name, notifier_class, = {}) @name = name @notifier_class = notifier_class @options = .extract!(*RESERVED_KEYS) @args = end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/active_notify/carrier_descriptor.rb', line 7 def name @name end |
Instance Method Details
#args(context) ⇒ Object
21 22 23 |
# File 'lib/active_notify/carrier_descriptor.rb', line 21 def args(context) @args.transform_values { |value| compute(value, context) } end |
#constant ⇒ Object
16 17 18 19 |
# File 'lib/active_notify/carrier_descriptor.rb', line 16 def constant return @options[:class_name].constantize if @options[:class_name] @notifier_class.const_get(name.to_s.classify) end |
#deliver?(context) ⇒ Boolean
25 26 27 28 29 |
# File 'lib/active_notify/carrier_descriptor.rb', line 25 def deliver?(context) return false if .key?(:if) && !evaluate(:if, context) return false if .key?(:unless) && evaluate(:unless, context) true end |