Module: ArchSpec::DSL::Context

Defined in:
lib/archspec/dsl.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name) ⇒ Object



54
55
56
57
58
# File 'lib/archspec/dsl.rb', line 54

def method_missing(name, ...)
  return ComponentProxy.new(self, name) if component?(name)

  super
end

Instance Method Details

#architecture(name, **options) ⇒ Object



38
39
40
# File 'lib/archspec/dsl.rb', line 38

def architecture(name, **options)
  Architectures.apply(name, self, **options)
end

#baseline(path = '.archspec_todo.yml') ⇒ Object



20
21
22
# File 'lib/archspec/dsl.rb', line 20

def baseline(path = '.archspec_todo.yml')
  self.baseline_path = path.to_s
end

#component(name, in: nil, namespace: nil, constants: nil) ⇒ Object Also known as: layer, role



24
25
26
27
28
29
# File 'lib/archspec/dsl.rb', line 24

def component(name, in: nil, namespace: nil, constants: nil)
  add_component(
    ComponentSpec.new(name, files: binding.local_variable_get(:in), namespace: namespace, constants: constants)
  )
  ComponentProxy.new(self, name)
end

#ignore(*patterns) ⇒ Object



16
17
18
# File 'lib/archspec/dsl.rb', line 16

def ignore(*patterns)
  add_ignore_patterns(patterns)
end

#no_cycles!(among: nil) ⇒ Object



42
43
44
# File 'lib/archspec/dsl.rb', line 42

def no_cycles!(among: nil)
  add_rule(Rules::NoCyclesRule.new(among: among))
end

#preset(name, **options) ⇒ Object



34
35
36
# File 'lib/archspec/dsl.rb', line 34

def preset(name, **options)
  Presets.apply(name, self, **options)
end

#respond_to_missing?(name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/archspec/dsl.rb', line 60

def respond_to_missing?(name, include_private = false)
  component?(name) || super
end

#root(path = nil) ⇒ Object



6
7
8
9
10
# File 'lib/archspec/dsl.rb', line 6

def root(path = nil)
  return root_path unless path

  self.root_path = path.to_s
end

#rule(rule) ⇒ Object



50
51
52
# File 'lib/archspec/dsl.rb', line 50

def rule(rule)
  add_rule(rule)
end

#source(*patterns) ⇒ Object



12
13
14
# File 'lib/archspec/dsl.rb', line 12

def source(*patterns)
  add_source_patterns(patterns)
end

#verify_zeitwerk_names!Object



46
47
48
# File 'lib/archspec/dsl.rb', line 46

def verify_zeitwerk_names!
  add_rule(Rules::ZeitwerkNamingRule.new)
end