Module: ActiveAdmin::Dependency

Defined in:
lib/active_admin/dependency.rb

Defined Under Namespace

Modules: Requirements Classes: Matcher

Class Method Summary collapse

Class Method Details

.[](name) ⇒ Object


54
55
56
# File 'lib/active_admin/dependency.rb', line 54

def self.[](name)
  Matcher.new name.to_s
end

.method_missing(name, *args) ⇒ Object

Provides a clean interface to check for gem dependencies at runtime.

ActiveAdmin::Dependency.rails

> #<ActiveAdmin::Dependency::Matcher for rails 6.0.3.2>

ActiveAdmin::Dependency.rails?

> true

ActiveAdmin::Dependency.rails? '>= 6.1'

> false

ActiveAdmin::Dependency.rails? '= 6.0.3.2'

> true

ActiveAdmin::Dependency.rails? '~> 6.0.3'

> true

ActiveAdmin::Dependency.rails? '>= 6.0.3', '<= 6.1.0'

> 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.

ActiveAdmin::Dependency < 5

> false


44
45
46
47
48
49
50
51
52
# 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

.supports_zeitwerk?Boolean

Returns:

  • (Boolean)

58
59
60
# File 'lib/active_admin/dependency.rb', line 58

def self.supports_zeitwerk?
  rails >= "6.0.0.beta3" && RUBY_ENGINE != "jruby"
end