Sha256: a8929e9d4900a374bba5122dd8488e1a7f5b7b8b5793aeafd933774519790086

Contents?: true

Size: 688 Bytes

Versions: 3

Compression:

Stored size: 688 Bytes

Contents

require 'sfkb/rest'
require 'sfkb/settings'
require 'sfkb/decoration'

module SFKB
  module Knowledge
    include REST
    include Settings
    include Decoration

    # Queries for all (undeleted) article IDs, returning an array.
    def article_ids
      query('SELECT Id FROM KnowledgeArticle').map(&:Id)
    end

    # Enumerates articles
    def articles
      Enumerator.new do |y|
        article_ids.each do |id|
          y << article(id)
        end
      end
    end

    # Gets an article by ID
    def article(id)
      url = index.knowledgeManagement.articles.article
      url = url(url, ArticleID: id)
      decorate(get(url).body) { |o| autodefine(o) }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sfkb-0.1.3 lib/sfkb/knowledge.rb
sfkb-0.1.2 lib/sfkb/knowledge.rb
sfkb-0.1.0 lib/sfkb/knowledge.rb