Class: Dry::System::Provider::SourceDSL Private

Inherits:
Object
  • Object
show all
Defined in:
lib/dry/system/provider/source_dsl.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Configures a Dry::System::Provider::Source subclass using a DSL that makes it nicer to define source behaviour via a single block.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source_class) ⇒ SourceDSL

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of SourceDSL.



19
20
21
# File 'lib/dry/system/provider/source_dsl.rb', line 19

def initialize(source_class)
  @source_class = source_class
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



41
42
43
44
45
46
47
# File 'lib/dry/system/provider/source_dsl.rb', line 41

def method_missing(name, *args, &block)
  if source_class.respond_to?(name)
    source_class.public_send(name, *args, &block)
  else
    super
  end
end

Instance Attribute Details

#source_classObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



17
18
19
# File 'lib/dry/system/provider/source_dsl.rb', line 17

def source_class
  @source_class
end

Class Method Details

.evaluate(source_class, &block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



13
14
15
# File 'lib/dry/system/provider/source_dsl.rb', line 13

def self.evaluate(source_class, &block)
  new(source_class).instance_eval(&block)
end

Instance Method Details

#prepare(&block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



27
28
29
# File 'lib/dry/system/provider/source_dsl.rb', line 27

def prepare(&block)
  source_class.define_method(:prepare, &block)
end

#settingObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



23
24
25
# File 'lib/dry/system/provider/source_dsl.rb', line 23

def setting(...)
  source_class.setting(...)
end

#start(&block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



31
32
33
# File 'lib/dry/system/provider/source_dsl.rb', line 31

def start(&block)
  source_class.define_method(:start, &block)
end

#stop(&block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



35
36
37
# File 'lib/dry/system/provider/source_dsl.rb', line 35

def stop(&block)
  source_class.define_method(:stop, &block)
end