Class: Rufio::DslCommandLoader::DslContext
- Inherits:
- BasicObject
- Defined in:
- lib/rufio/dsl_command_loader.rb
Overview
DSL評価用の独立したコンテキスト
Instance Attribute Summary collapse
-
#commands ⇒ Object
readonly
Returns the value of attribute commands.
Instance Method Summary collapse
-
#command(name) { ... } ⇒ Object
コマンドを定義する.
-
#initialize ⇒ DslContext
constructor
A new instance of DslContext.
-
#method_missing(method_name, *_args) ⇒ Object
安全でないメソッドをブロック.
- #respond_to_missing?(_method_name, _include_private = false) ⇒ Boolean
Constructor Details
#initialize ⇒ DslContext
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
#commands ⇒ Object (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
コマンドを定義する
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
117 118 119 |
# File 'lib/rufio/dsl_command_loader.rb', line 117 def respond_to_missing?(_method_name, _include_private = false) false end |