Class: MeducationSDK::CollectionTopic

Inherits:
Resource
  • Object
show all
Defined in:
lib/meducation_sdk/resources/collection_topic.rb

Direct Known Subclasses

CollectionTopicMock

Constant Summary

Constants included from Helpers

Helpers::SDK_TO_SPI_MAPPINGS

Instance Method Summary collapse

Methods inherited from Resource

#created_at, spi_type=, #updated_at

Methods included from Helpers

#sdk_class_for, #sdk_type_for, #spi_type_for

Instance Method Details

#authorsObject



11
12
13
# File 'lib/meducation_sdk/resources/collection_topic.rb', line 11

def authors
  @authors ||= Author.where(id: author_ids)
end

#collectionObject



7
8
9
# File 'lib/meducation_sdk/resources/collection_topic.rb', line 7

def collection
  @collection ||= Collection.find(collection_id)
end

#commentsObject



19
20
21
# File 'lib/meducation_sdk/resources/collection_topic.rb', line 19

def comments
  @comments ||= Comment.where(id: comment_ids)
end

#item_mesh_headingsObject



23
24
25
26
27
28
29
# File 'lib/meducation_sdk/resources/collection_topic.rb', line 23

def item_mesh_headings
  @item_mesh_headings ||= begin
    @data['item_mesh_headings'].map do |imh|
      ItemMeshHeading.new(item_id: imh['item_id'], item_type: imh['item_type'], mesh_root: imh['mesh_root'], mesh_heading: imh['mesh_heading'], relevance: imh['relevance'])
    end
  end
end

#usersObject



15
16
17
# File 'lib/meducation_sdk/resources/collection_topic.rb', line 15

def users
  @users ||= User.where(id: authors.map(&:user_id))
end