Class: Necromancy::Necromancy
- Inherits:
- BasicObject
- Defined in:
- lib/necromancy/necromancy.rb
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object (protected)
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/necromancy/necromancy.rb', line 13 def method_missing(name, *args, &block) getproc = ":#{name}.to_proc" if args.size == 0 getargs = nil elsif args.size == 1 getargs = ", (#{make_evaluable_literal(args[0])})" else getargs = ", *(#{make_evaluable_literal(args)})" end if block getblock = ", &(#{make_evaluable_literal(block)})" else getblock = nil end necromancy = "[#{getproc}.(*(#{@necromancy})#{getargs}#{getblock})]" self.class.new(necromancy, @references.dup) end |