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



52
53
54
55
56
# File 'lib/archspec/dsl.rb', line 52

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

  super
end

Instance Method Details

#architecture(name, **options) ⇒ Object



36
37
38
# File 'lib/archspec/dsl.rb', line 36

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

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



18
19
20
# File 'lib/archspec/dsl.rb', line 18

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



22
23
24
25
26
27
# File 'lib/archspec/dsl.rb', line 22

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



14
15
16
# File 'lib/archspec/dsl.rb', line 14

def ignore(*patterns)
  add_ignore_patterns(patterns)
end

#no_cycles!(among: nil) ⇒ Object



40
41
42
# File 'lib/archspec/dsl.rb', line 40

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

#preset(name, **options) ⇒ Object



32
33
34
# File 'lib/archspec/dsl.rb', line 32

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

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

Returns:

  • (Boolean)


58
59
60
# File 'lib/archspec/dsl.rb', line 58

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

#root(path = nil) ⇒ Object



4
5
6
7
8
# File 'lib/archspec/dsl.rb', line 4

def root(path = nil)
  return root_path unless path

  self.root_path = path.to_s
end

#rule(rule) ⇒ Object



48
49
50
# File 'lib/archspec/dsl.rb', line 48

def rule(rule)
  add_rule(rule)
end

#source(*patterns) ⇒ Object



10
11
12
# File 'lib/archspec/dsl.rb', line 10

def source(*patterns)
  add_source_patterns(patterns)
end

#verify_zeitwerk_names!Object



44
45
46
# File 'lib/archspec/dsl.rb', line 44

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