Open gnecula opened 9 years ago
It doesn't allow for 'if bond.testing' at the moment; good point. I created DUMMY_BOND so that it isn't creating and instantiating a new class on each call to Bond, since this is supposed to be for production code, but it's definitely not ideal. I was hoping to discuss some of the implementation details with you when we met these week because there are some oddities that I was hoping to get your opinion on.
Erik
On Wednesday, October 21, 2015, George Necula notifications@github.com wrote:
I do not understand this safe import. Does this allow "if bond.testing" ? Why do we need the DUMMY_BOND name, can't we just assign to bond directly?
begin require 'bond' rescue LoadError module BondTargetable DUMMY_BOND = Class.new { def method_missing(meth, *args); end }.new def self.included(base); base.extend(BondTargetable); end def bond; DUMMY_BOND; end end end
— Reply to this email directly or view it on GitHub https://github.com/necula01/bond/issues/16.
I do not understand this safe import. Does this allow "if bond.testing" ? Why do we need the DUMMY_BOND name, can't we just assign to bond directly?
begin require 'bond' rescue LoadError module BondTargetable DUMMY_BOND = Class.new { def method_missing(meth, *args); end }.new def self.included(base); base.extend(BondTargetable); end def bond; DUMMY_BOND; end end end