module Chef::EncryptedAttribute::Yajl

Helper module to abstract the required Yajl (JSON) dependecy.

Public Class Methods

load_requirement(chef_version) click to toggle source

Loads the required Yajl JSON library depending on the installed Chef version.

  • Loads the `yajl` gem in Chef `< 11.13`.

  • Loads the `ffi_yajl` gem in Chef `>= 11.13`.

@return [Class] The correct JSON class to use.

# File lib/chef/encrypted_attribute/yajl.rb, line 32
def self.load_requirement(chef_version)
  if Gem::Requirement.new('< 11.13').satisfied_by?(
    Gem::Version.new(chef_version)
  )
    require 'yajl'
    ::Yajl
  else
    require 'ffi_yajl'
    ::FFI_Yajl
  end
end