Class: Packwerk::Layer::Layers

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/packwerk/layer/layers.rb

Instance Method Summary collapse

Constructor Details

#initializeLayers

Returns a new instance of Layers.



10
11
12
13
# File 'lib/packwerk/layer/layers.rb', line 10

def initialize
  @names = T.let(@names, T.nilable(T::Set[String]))
  @names_list = T.let(@names_list, T.nilable(T::Array[String]))
end

Instance Method Details

#index_of(layer) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/packwerk/layer/layers.rb', line 16

def index_of(layer)
  index = names_list.reverse.find_index(layer)
  if index.nil?
    raise "Layer #{layer} not find, please run `bin/packwerk validate`"
  end

  index
end

#namesObject



26
27
28
# File 'lib/packwerk/layer/layers.rb', line 26

def names
  @names ||= Set.new(names_list)
end

#names_listObject



31
32
33
# File 'lib/packwerk/layer/layers.rb', line 31

def names_list
  @names_list ||= Config.new.layers_list
end