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.



113
114
115
# File 'lib/lazylead/cc.rb', line 113

def initialize(orig)
  @orig = orig
end

Instance Method Details

#[](key) ⇒ Object



117
118
119
# File 'lib/lazylead/cc.rb', line 117

def [](key)
  to_h[key]
end

#cc(*names) ⇒ Object



121
122
123
124
125
# File 'lib/lazylead/cc.rb', line 121

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



127
128
129
130
131
132
133
134
135
136
137
# File 'lib/lazylead/cc.rb', line 127

def to_h
  @to_h ||= begin
    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
end