Class: CommandTower::Messaging::Planner::MessageOverrides
- Inherits:
-
Data
- Object
- Data
- CommandTower::Messaging::Planner::MessageOverrides
- Defined in:
- app/services/command_tower/messaging/planner/message_overrides.rb
Constant Summary collapse
- FORBIDDEN_KEYS =
%w[force_mandatory mandatory elevate_mandatory].freeze
Instance Attribute Summary collapse
-
#channels_add ⇒ Object
readonly
Returns the value of attribute channels_add.
-
#channels_remove ⇒ Object
readonly
Returns the value of attribute channels_remove.
-
#inbox ⇒ Object
readonly
Returns the value of attribute inbox.
Class Method Summary collapse
Instance Attribute Details
#channels_add ⇒ Object (readonly)
Returns the value of attribute channels_add
6 7 8 |
# File 'app/services/command_tower/messaging/planner/message_overrides.rb', line 6 def channels_add @channels_add end |
#channels_remove ⇒ Object (readonly)
Returns the value of attribute channels_remove
6 7 8 |
# File 'app/services/command_tower/messaging/planner/message_overrides.rb', line 6 def channels_remove @channels_remove end |
#inbox ⇒ Object (readonly)
Returns the value of attribute inbox
6 7 8 |
# File 'app/services/command_tower/messaging/planner/message_overrides.rb', line 6 def inbox @inbox end |
Class Method Details
.normalize(raw) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/services/command_tower/messaging/planner/message_overrides.rb', line 9 def self.normalize(raw) return nil if raw.nil? unless raw.respond_to?(:to_h) raise IllegalOverrideError, "message_overrides must be a hash-like object" end hash = raw.to_h.transform_keys(&:to_s) FORBIDDEN_KEYS.each do |key| if hash.key?(key) raise IllegalOverrideError, "message_overrides cannot include #{key}" end end channels_add = Array(hash["channels_add"]).map(&:to_s).freeze channels_remove = Array(hash["channels_remove"]).map(&:to_s).freeze inbox = hash.key?("inbox") ? !!hash["inbox"] : nil new(channels_add:, channels_remove:, inbox:).freeze end |