Class: Method::Probe
Instance Attribute Summary collapse
-
#decoys ⇒ Object
readonly
Returns the value of attribute decoys.
-
#ducks ⇒ Object
readonly
Returns the value of attribute ducks.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Probe
constructor
A new instance of Probe.
- #initialize_copy(from) ⇒ Object
- #method_missing(aSym, *args) ⇒ Object
Constructor Details
#initialize ⇒ Probe
Returns a new instance of Probe.
84 85 86 |
# File 'lib/mega/methodprobe.rb', line 84 def initialize @ducks, @decoys = {}, {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(aSym, *args) ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/mega/methodprobe.rb', line 92 def method_missing(aSym, *args) aSymStr = aSym.to_s # This will happen the first time @ducks[aSymStr] ||= [] #unless @ducks[aSymStr] @ducks[aSymStr] << args.collect { |a| "#{a.class}" } decoy = self.dup @decoys[aSymStr] ||= [] #unless @decoys[aSymStr] @decoys[aSymStr] << decoy # build proxy? #begin # d = <<-HERE # def self.#{aSymStr}(*args) # # This will happen the subsequent times # @ducks["#{aSymStr}"] << args.collect { |a| #{'"#{a.class}"'} } # @ducks["#{aSymStr}"].uniq! # decoy = self.dup # @decoys["#{aSymStr}"] = [] unless @decoys["#{aSymStr}"] # @decoys["#{aSymStr}"] << decoy # decoy # end # HERE # instance_eval d #rescue SyntaxError # puts "This error may be avoidable by returning the failing duck type as the error message." # raise #end decoy end |
Instance Attribute Details
#decoys ⇒ Object (readonly)
Returns the value of attribute decoys.
82 83 84 |
# File 'lib/mega/methodprobe.rb', line 82 def decoys @decoys end |
#ducks ⇒ Object (readonly)
Returns the value of attribute ducks.
82 83 84 |
# File 'lib/mega/methodprobe.rb', line 82 def ducks @ducks end |
Class Method Details
Instance Method Details
#initialize_copy(from) ⇒ Object
88 89 90 |
# File 'lib/mega/methodprobe.rb', line 88 def initialize_copy(from) initialize end |