Class: ImperiusGem::Thing

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

Instance Method Summary collapse

Constructor Details

#initialize(d, on) ⇒ Thing

Returns a new instance of Thing.



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

def initialize(d,on)
  @d = d
  @on = on
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



12
13
14
15
16
# File 'lib/thing.rb', line 12

def method_missing(meth, *args, &block)
  method = meth.to_s
  super if method == "initialize"
  @d.run(@on,method,fix_args(args))
end

Instance Method Details

#fix_args(args) ⇒ Object



18
19
20
# File 'lib/thing.rb', line 18

def fix_args(args)
  args.map { |arg| (arg.is_a? Thing) ? arg.on : arg }
end

#onObject



10
# File 'lib/thing.rb', line 10

def on; @on; end