class ActiveAdmin::Dependency::Matcher

Attributes

name[R]

Public Class Methods

new(name) click to toggle source
# File lib/active_admin/dependency.rb, line 65
def initialize(name)
  @name = name
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/active_admin/dependency.rb, line 89
def <=>(other)
  spec!.version <=> Gem::Version.create(other)
end
adapter() click to toggle source
# File lib/active_admin/dependency.rb, line 98
def adapter
  @adapter ||= Adapter.const_get(@name.camelize).new self
end
inspect() click to toggle source
# File lib/active_admin/dependency.rb, line 93
def inspect
  info = spec ? "#{spec.name} #{spec.version}" : '(missing)'
  "<ActiveAdmin::Dependency::Matcher for #{info}>"
end
match!(*reqs) click to toggle source
# File lib/active_admin/dependency.rb, line 81
def match!(*reqs)
  unless match? reqs
    raise DependencyError, "You provided #{spec!.name} #{spec!.version} but we need: #{reqs.join ', '}."
  end
end
match?(*reqs) click to toggle source
# File lib/active_admin/dependency.rb, line 77
def match?(*reqs)
  !!spec && Gem::Requirement.create(reqs).satisfied_by?(spec.version)
end
method_missing(method, *args, &block) click to toggle source
Calls superclass method
# File lib/active_admin/dependency.rb, line 102
def method_missing(method, *args, &block)
  if respond_to_missing?(method)
    adapter.send method, *args, &block
  else
    super
  end
end
respond_to_missing?(method, include_private = false) click to toggle source
Calls superclass method
# File lib/active_admin/dependency.rb, line 110
def respond_to_missing?(method, include_private = false)
  adapter.respond_to?(method) || super
rescue NameError
  # 🐾
end
spec() click to toggle source
# File lib/active_admin/dependency.rb, line 69
def spec
  @spec ||= Gem.loaded_specs[name]
end
spec!() click to toggle source
# File lib/active_admin/dependency.rb, line 73
def spec!
  spec || raise(DependencyError, "To use #{name} you need to specify it in your Gemfile.")
end