Class: Interactify::Wiring::Constants

Inherits:
Object
  • Object
show all
Defined in:
lib/interactify/wiring/constants.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root:, organizer_files:, interactor_files:) ⇒ Constants

Returns a new instance of Constants.



8
9
10
11
12
# File 'lib/interactify/wiring/constants.rb', line 8

def initialize(root:, organizer_files:, interactor_files:)
  @root = root.is_a?(Pathname) ? root : Pathname.new(root)
  @organizer_files = organizer_files
  @interactor_files = interactor_files
end

Instance Attribute Details

#interactor_filesObject (readonly)

Returns the value of attribute interactor_files.



6
7
8
# File 'lib/interactify/wiring/constants.rb', line 6

def interactor_files
  @interactor_files
end

#organizer_filesObject (readonly)

Returns the value of attribute organizer_files.



6
7
8
# File 'lib/interactify/wiring/constants.rb', line 6

def organizer_files
  @organizer_files
end

#rootObject (readonly)

Returns the value of attribute root.



6
7
8
# File 'lib/interactify/wiring/constants.rb', line 6

def root
  @root
end

Instance Method Details

#interactor_lookupObject



26
27
28
# File 'lib/interactify/wiring/constants.rb', line 26

def interactor_lookup
  @interactor_lookup ||= (interactors + organizers).index_by(&:klass)
end

#interactorsObject



20
21
22
23
24
# File 'lib/interactify/wiring/constants.rb', line 20

def interactors
  @interactors ||= interactor_files.flat_map do |f|
    callables_in_file(f)
  end.compact.reject(&:organizer?)
end

#organizersObject



14
15
16
17
18
# File 'lib/interactify/wiring/constants.rb', line 14

def organizers
  @organizers ||= organizer_files.flat_map do |f|
    callables_in_file(f)
  end.compact.select(&:organizer?)
end