module ActiveAdmin::Dependency
Public Class Methods
[](name)
click to toggle source
# File lib/active_admin/dependency.rb, line 54 def self.[](name) Matcher.new name.to_s end
method_missing(name, *args)
click to toggle source
Provides a clean interface to check for gem dependencies at runtime.
ActiveAdmin::Dependency.draper
> #<ActiveAdmin::Dependency::Matcher for draper 1.2.1>¶ ↑
ActiveAdmin::Dependency.draper?
> true¶ ↑
ActiveAdmin::Dependency.draper? '>= 1.5.0'
> false¶ ↑
ActiveAdmin::Dependency.draper? '= 1.2.1'
> true¶ ↑
ActiveAdmin::Dependency.draper? '~> 1.2.0'
> true¶ ↑
ActiveAdmin::Dependency.rails? '>= 4.2.7', '<= 5.0.2'
> true¶ ↑
ActiveAdmin::Dependency.rails! '5' -> ActiveAdmin::DependencyError: You provided rails 4.2.7 but we need: 5.
ActiveAdmin::Dependency.devise! -> ActiveAdmin::DependencyError: To use devise you need to specify it in your Gemfile.
All but the pessimistic operator (~>) can also be run using Ruby's comparison syntax.
ActiveAdmin::Dependency.rails >= '4.2.7'
> true¶ ↑
Which is especially useful if you're looking up a gem with dashes in the name.
> false¶ ↑
# File lib/active_admin/dependency.rb, line 44 def self.method_missing(name, *args) if name[-1] == '?' Matcher.new(name[0..-2]).match? args elsif name[-1] == '!' Matcher.new(name[0..-2]).match! args else Matcher.new name.to_s end end