Class: Shorthand::Provider

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

Instance Method Summary collapse

Constructor Details

#initialize(target, &block) ⇒ Provider

Returns a new instance of Provider.



28
29
30
31
32
33
34
35
# File 'lib/shorthand.rb', line 28

def initialize(target, &block)
  @target = target
  if block.arity == 1
    yield self
  else
    instance_eval(&block)
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/shorthand.rb', line 36

def method_missing(meth, *args, &block)
  if @target.respond_to?(message = "#{meth}=", true)
    @target.__send__(message, *args, &block)
  else
    super
  end
end