Class: Lazylead::PredefinedCC

Inherits:
Object
  • Object
show all
Defined in:
lib/lazylead/cc.rb

Overview

Predefined CC addresses for email notification. You may define a hash where

- key is Jira ticket component
- value is CC email address(es)
Author

Yurii Dubinka ([email protected])

Copyright

Copyright © 2019-2020 Yurii Dubinka

License

MIT

Direct Known Subclasses

ComponentCC

Instance Method Summary collapse

Constructor Details

#initialize(orig) ⇒ PredefinedCC

Returns a new instance of PredefinedCC.



111
112
113
# File 'lib/lazylead/cc.rb', line 111

def initialize(orig)
  @orig = orig
end

Instance Method Details

#[](key) ⇒ Object



115
116
117
# File 'lib/lazylead/cc.rb', line 115

def [](key)
  to_h[key]
end

#cc(*names) ⇒ Object



119
120
121
122
123
# File 'lib/lazylead/cc.rb', line 119

def cc(*names)
  return to_h.values.flatten.uniq.compact if names.count.zero?
  return self[names.first] if names.count == 1
  to_h.values_at(names.first, *names.drop(1)).flatten.uniq.compact
end

#to_hObject



125
126
127
128
129
130
131
132
133
# File 'lib/lazylead/cc.rb', line 125

def to_h
  @to_h ||= if @orig.is_a? Hash
              @orig.each_with_object({}) do |i, o|
                o[i.first] = Lazylead::PlainCC.new(i.last).cc
              end
            else
              {}
            end
end