Class: Forwarder::Compiler

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

Overview

The compiler’s responsability is to create a string representation of the delegation method, or to nil if no such string representation exists and delegation has to be done dynamically.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#argumentsObject (readonly)

Returns the value of attribute arguments.



7
8
9
# File 'lib/forwarder/compiler.rb', line 7

def arguments
  @arguments
end

Class Method Details

.compile_target(target) ⇒ Object



58
59
60
# File 'lib/forwarder/compiler.rb', line 58

def compile_target target
  [ target ].flatten.join( "." )
end

Instance Method Details

#compileObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/forwarder/compiler.rb', line 10

def compile
  # Cannot compile because of intrinsic uncompilable traits of arguments
  return if arguments.must_not_compile?

  # To Hash can always compile
  return compile_to_hash if arguments.to_hash?

  # Cannot compile only because the arguments.args cannot be compiled
  @compiled_args = Evaller.serialize arguments.args
  return unless @compiled_args

  # Can compile :)))
  return compile_to_all if arguments.message.is_a? Array
  compile_one
end