Sha256: 31528fa1c1824c52a63d52d4c834ca38a9dcd2afa285326b6a78b4cc55da868a

Contents?: true

Size: 704 Bytes

Versions: 1

Compression:

Stored size: 704 Bytes

Contents

# frozen_string_literal: true

module PuppetLanguageServer
  module FacterHelper
    # Facts
    def self.fact(session_state, name)
      session_state.object_cache.object_by_name(:fact, name)
    end

    def self.fact_value(session_state, name)
      object = session_state.object_cache.object_by_name(:fact, name)
      object.nil? ? nil : object.value
    end

    def self.fact_names(session_state)
      session_state.object_cache.object_names_by_section(:fact).map(&:to_s)
    end

    def self.facts_to_hash(session_state)
      fact_hash = {}
      session_state.object_cache.objects_by_section(:fact) { |factname, fact| fact_hash[factname.to_s] = fact.value }
      fact_hash
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
puppet-editor-services-2.0.4 lib/puppet-languageserver/facter_helper.rb