Module: Chef::EncryptedAttribute::Yajl

Defined in:
lib/chef/encrypted_attribute/yajl.rb

Overview

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

Class Method Summary collapse

Class Method Details

.load_requirement(chef_version) ⇒ Class

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.

Returns:

  • (Class)

    The correct JSON class to use.



32
33
34
35
36
37
38
39
40
41
42
# 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