Class: Rufio::DslCommandLoader::DslContext

Inherits:
BasicObject
Defined in:
lib/rufio/dsl_command_loader.rb

Overview

DSL評価用の独立したコンテキスト

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDslContext

Returns a new instance of DslContext.



99
100
101
# File 'lib/rufio/dsl_command_loader.rb', line 99

def initialize
  @commands = []
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *_args) ⇒ Object

安全でないメソッドをブロック



113
114
115
# File 'lib/rufio/dsl_command_loader.rb', line 113

def method_missing(method_name, *_args)
  ::Kernel.raise ::NoMethodError, "Method '#{method_name}' is not allowed in DSL"
end

Instance Attribute Details

#commandsObject (readonly)

Returns the value of attribute commands.



97
98
99
# File 'lib/rufio/dsl_command_loader.rb', line 97

def commands
  @commands
end

Instance Method Details

#command(name) { ... } ⇒ Object

コマンドを定義する

Parameters:

  • name (String)

    コマンド名

Yields:

  • コマンドの設定ブロック



106
107
108
109
110
# File 'lib/rufio/dsl_command_loader.rb', line 106

def command(name, &block)
  builder = CommandBuilder.new(name)
  builder.instance_eval(&block) if block
  @commands << builder.build
end

#respond_to_missing?(_method_name, _include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


117
118
119
# File 'lib/rufio/dsl_command_loader.rb', line 117

def respond_to_missing?(_method_name, _include_private = false)
  false
end