Module: DataBindings::GemRequirement::ClassMethods

Defined in:
lib/data_bindings/util.rb

Instance Method Summary collapse

Instance Method Details

#gentle_require_gem(method, gem) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/data_bindings/util.rb', line 53

def gentle_require_gem(method, gem)
  class_eval <<-EOT, __FILE__, __LINE__ + 1
    alias_method :#{method}_without_gem, :#{method}
    def #{method}(*args, &blk)
      DataBindings::GemRequirement.gentle_require_gem #{gem.to_s.inspect}
      class << self
        self
      end.instance_eval do
        alias_method :#{method}, :#{method}_without_gem
      end
      #{method}(*args, &blk)
    end
  EOT
end