Skip to content

ruby safe import in production code #16

@gnecula

Description

@gnecula

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions