Module: Destructure

Includes:
Paramix::Parametric
Defined in:
lib/destructure/destructure.rb,
lib/destructure/sexp_transformer.rb

Defined Under Namespace

Classes: SexpTransformer

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



79
80
81
82
83
84
85
86
87
88
# File 'lib/destructure/destructure.rb', line 79

def method_missing(name, *args, &block)
  if bind_locals
    c = caller_locations(1,1)[0].label
    @_destructure_env ||= {}
    caller_hash = @_destructure_env[c]
    caller_hash && caller_hash.keys.include?(name) ? caller_hash[name] : super
  else
    super
  end
end

Instance Method Details

#dbind(x, &pat_block) ⇒ Object



35
36
37
# File 'lib/destructure/destructure.rb', line 35

def dbind(x, &pat_block)
  dbind_internal(x, pat_block.to_sexp(strip_enclosure: true, ignore_nested: true), binding.of_caller(1), caller_locations(1,1)[0].label)
end