Class: Ecfr::VersionerService::Topic
- Extended by:
- ResponseHelper
- Defined in:
- lib/ecfr/versioner_service/topic.rb,
lib/ecfr/testing/extensions/versioner_service/topic_extensions.rb
Overview
Topics represent entries in the CFR Index and Finding Aids.
Each topic contains a name and may have references to specific CFR sections, see_also references to other topics, or see references for redirects.
Constant Summary collapse
- TOPICS_PATH =
/current | /2024
"v1/topics"
Instance Attribute Summary collapse
-
#adhoc ⇒ Boolean
readonly
distinguish informal topics from thesaurus entries.
-
#agencies ⇒ [Ecfr::VersionerService::Agency]
readonly
array of agencies referenced in topics.
-
#name ⇒ String
readonly
name of the topic.
-
#references ⇒ [Ecfr::VersionerService::Reference]
readonly
array of CFR references with descriptions.
-
#see ⇒ [:string]
readonly
array of topic names to redirect to.
-
#see_also ⇒ [:string]
readonly
array of related topic names to see also.
-
#slug ⇒ String
readonly
normalized topic identifier for URLs.
Class Method Summary collapse
-
.all(options = {}) ⇒ <Topic>
Retrieves the list of all Topics.
- .response_for(topics, meta: {}) ⇒ Object
Methods included from ResponseHelper
Methods inherited from Base
base_url, service_name, service_path
Instance Attribute Details
#adhoc ⇒ Boolean (readonly)
distinguish informal topics from thesaurus entries
13 14 15 |
# File 'lib/ecfr/versioner_service/topic.rb', line 13 attribute :adhoc, type: :boolean, desc: "distinguish informal topics from thesaurus entries" |
#agencies ⇒ [Ecfr::VersionerService::Agency] (readonly)
array of agencies referenced in topics
39 40 41 |
# File 'lib/ecfr/versioner_service/topic.rb', line 39 :agencies, type: Array(Ecfr::VersionerService::Agency), desc: "array of agencies referenced in topics" |
#name ⇒ String (readonly)
name of the topic
17 18 |
# File 'lib/ecfr/versioner_service/topic.rb', line 17 attribute :name, desc: "name of the topic" |
#references ⇒ [Ecfr::VersionerService::Reference] (readonly)
array of CFR references with descriptions
20 21 22 |
# File 'lib/ecfr/versioner_service/topic.rb', line 20 :references, type: Array(Ecfr::VersionerService::Reference), desc: "array of CFR references with descriptions" |
#see ⇒ [:string] (readonly)
array of topic names to redirect to
28 29 30 |
# File 'lib/ecfr/versioner_service/topic.rb', line 28 attribute :see, type: Array(:string), desc: "array of topic names to redirect to" |
#see_also ⇒ [:string] (readonly)
array of related topic names to see also
24 25 26 |
# File 'lib/ecfr/versioner_service/topic.rb', line 24 attribute :see_also, type: Array(:string), desc: "array of related topic names to see also" |
#slug ⇒ String (readonly)
normalized topic identifier for URLs
32 33 |
# File 'lib/ecfr/versioner_service/topic.rb', line 32 attribute :slug, desc: "normalized topic identifier for URLs" |
Class Method Details
.all(options = {}) ⇒ <Topic>
Retrieves the list of all Topics
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/ecfr/versioner_service/topic.rb', line 56 def self.all( = {}) year = .fetch(:year, "current") include_agencies = .fetch(:include_agencies, false) params = {} params[:include_agencies] = true if include_agencies perform( :get, "#{TOPICS_PATH}/#{year}", params: params, perform_options: { attributes_key: nil } ) end |
.response_for(topics, meta: {}) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/ecfr/testing/extensions/versioner_service/topic_extensions.rb', line 4 def self.response_for(topics, meta: {}) topics = topics.is_a?(Array) ? topics : [topics] results = { topics: topics, meta: }.compact build( response: stubbed_response(results.to_json) ) end |