Class: Evil::Client::DSL::Scope

Inherits:
Object
  • Object
show all
Extended by:
Dry::Initializer::Mixin
Defined in:
lib/evil/client/dsl/scope.rb

Overview

Provides a namespace for client’s top-level DSL

Class Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



29
30
31
32
# File 'lib/evil/client/dsl/scope.rb', line 29

def method_missing(name, *args)
  super unless respond_to? name
  __scope__.send(name, *args)
end

Class Method Details

.scope(name = :[], &block) ⇒ self

Declares a method that opens new scope inside the current one An instance of new scope has access to methods of its parent

Parameters:

  • name (#to_sym) (defaults to: :[])

    (:[]) The name of the new scope

Returns:

  • (self)


13
14
15
16
17
18
19
# File 'lib/evil/client/dsl/scope.rb', line 13

def self.scope(name = :[], &block)
  klass = Class.new(Scope, &block)
  define_method(name) do |*args, **options|
    klass.new(*args, __scope__: self, **options)
  end
  self
end