Class: PatternMatching::MatchExec::ExecuteAs

Inherits:
Object
  • Object
show all
Defined in:
lib/patternmatching/pattern.rb

Overview

Private class enabling to use the name of symbols in patterns like a local variables in action blocks

Instance Method Summary collapse

Constructor Details

#initialize(args, receiver) ⇒ ExecuteAs

Returns a new instance of ExecuteAs.



249
250
251
252
253
# File 'lib/patternmatching/pattern.rb', line 249

def initialize(args, receiver)
  @receiver = receiver
  @wrapper = InstanceVariableAccessor.new receiver
  @args = args
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



261
262
263
264
# File 'lib/patternmatching/pattern.rb', line 261

def method_missing(name, *args)
  return @args[name] if @args.key?(name)
  @receiver.send(name, *args)
end

Instance Method Details

#theObject



257
258
259
# File 'lib/patternmatching/pattern.rb', line 257

def the
  @wrapper
end

#thisObject



254
255
256
# File 'lib/patternmatching/pattern.rb', line 254

def this
  @receiver
end