Class: Called

Inherits:
Object
  • Object
show all
Defined in:
lib/called.rb,
lib/called/version.rb

Defined Under Namespace

Classes: LogFile, Record

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(obj, path) ⇒ Called

Returns a new instance of Called.



10
11
12
13
# File 'lib/called.rb', line 10

def initialize obj, path
  @obj = obj
  @file = LogFile.new path
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *arg, &blk) ⇒ Object



15
16
17
18
# File 'lib/called.rb', line 15

def method_missing meth, *arg, &blk
  @file.puts Record.new meth, ::Kernel.caller[0]
  @obj.send meth, *arg, &blk
end

Class Method Details

.on(obj, path = {}) ⇒ Object



6
7
8
# File 'lib/called.rb', line 6

def self.on obj, path={}
  new obj, path[:log]
end