Class: HaveAPI::DocumentationSearch::Index

Inherits:
Object
  • Object
show all
Defined in:
lib/haveapi/documentation_search_index.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(description:, base_path:, version:, locale:, visibility:) ⇒ Index

Returns a new instance of Index.



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/haveapi/documentation_search_index.rb', line 9

def initialize(description:, base_path:, version:, locale:, visibility:)
  @payload = { format: 1, version: text(version), base_path: text(base_path), locale: text(locale),
               visibility: text(visibility), resources: [], actions: [], parameters: [] }
  resources(field(description, :resources, {}))
  field(description, :authentication, {}).sort_by { |name, _| name.to_s }.each do |provider, info|
    resources(field(info, :resources, {}), authentication: text(provider))
  end
  freeze_data(@payload)
  @key = Digest::SHA256.hexdigest(JSON.generate(@payload)).freeze
  freeze
end

Instance Attribute Details

#key ⇒ Object (readonly)

Returns the value of attribute key.



7
8
9
# File 'lib/haveapi/documentation_search_index.rb', line 7

def key
  @key
end

#payload ⇒ Object (readonly)

Returns the value of attribute payload.



7
8
9
# File 'lib/haveapi/documentation_search_index.rb', line 7

def payload
  @payload
end