Module: Forwarder::Meta
Defined Under Namespace
Classes: ObjectContainer
Instance Method Summary collapse
- #eval_body(application, as, to, with) ⇒ Object
- #eval_chain(names, context) ⇒ Object
- #eval_receiver(name, context) ⇒ Object
- #eval_receiver_body ⇒ Object
- #eval_symbolic_receiver(name, context) ⇒ Object
Instance Method Details
#eval_body(application, as, to, with) ⇒ Object
4 5 6 7 8 9 10 11 12 |
# File 'lib/forwarder/meta.rb', line 4 def eval_body application, as, to, with lambda do |*args, &blk| arguments = ( [ with ].flatten + args ).compact # rcv = __eval_receiver__( to ) rcv = Meta.eval_receiver to, self # p as: as, to: to, rcv: rcv, args: arguments, app: application, self: self rcv.send( as, *arguments, &(application||blk) ) end end |
#eval_chain(names, context) ⇒ Object
14 15 16 17 18 |
# File 'lib/forwarder/meta.rb', line 14 def eval_chain names, context names.inject context do | ctxt, name | Meta.eval_symbolic_receiver name, ctxt end end |
#eval_receiver(name, context) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/forwarder/meta.rb', line 20 def eval_receiver name, context case name when Proc context.instance_eval( &name ) when String, Symbol # p name: name, context: context Meta.eval_symbolic_receiver name, context when ObjectContainer name.object when Array Meta.eval_chain name, context end end |
#eval_receiver_body ⇒ Object
33 34 35 36 |
# File 'lib/forwarder/meta.rb', line 33 def eval_receiver_body lambda do | name | end end |
#eval_symbolic_receiver(name, context) ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/forwarder/meta.rb', line 38 def eval_symbolic_receiver name, context case "#{name}" when /\A@/ context.instance_variable_get name else context.send name end end |