Class: GdsApi::Panopticon::Registerer
- Inherits:
-
Object
- Object
- GdsApi::Panopticon::Registerer
- Defined in:
- lib/gds_api/panopticon/registerer.rb
Instance Attribute Summary collapse
-
#kind ⇒ Object
Returns the value of attribute kind.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#owning_app ⇒ Object
Returns the value of attribute owning_app.
-
#rendering_app ⇒ Object
Returns the value of attribute rendering_app.
Instance Method Summary collapse
-
#initialize(options) ⇒ Registerer
constructor
A new instance of Registerer.
- #record_to_artefact(record) ⇒ Object
-
#register(record) ⇒ Object
record should respond to #slug and #title, or override #record_to_artefact.
Constructor Details
#initialize(options) ⇒ Registerer
Returns a new instance of Registerer.
8 9 10 11 12 13 14 15 16 |
# File 'lib/gds_api/panopticon/registerer.rb', line 8 def initialize() @logger = [:logger] || GdsApi::Base.logger @owning_app = [:owning_app] @rendering_app = [:rendering_app] @kind = [:kind] || 'custom-application' @panopticon = [:panopticon] @endpoint_url = [:endpoint_url] || Plek.current.find("panopticon") @timeout = [:timeout] || 10 end |
Instance Attribute Details
#kind ⇒ Object
Returns the value of attribute kind.
6 7 8 |
# File 'lib/gds_api/panopticon/registerer.rb', line 6 def kind @kind end |
#logger ⇒ Object
Returns the value of attribute logger.
6 7 8 |
# File 'lib/gds_api/panopticon/registerer.rb', line 6 def logger @logger end |
#owning_app ⇒ Object
Returns the value of attribute owning_app.
6 7 8 |
# File 'lib/gds_api/panopticon/registerer.rb', line 6 def owning_app @owning_app end |
#rendering_app ⇒ Object
Returns the value of attribute rendering_app.
6 7 8 |
# File 'lib/gds_api/panopticon/registerer.rb', line 6 def rendering_app @rendering_app end |
Instance Method Details
#record_to_artefact(record) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/gds_api/panopticon/registerer.rb', line 18 def record_to_artefact(record) hash = { slug: record.slug, owning_app: owning_app, kind: kind, name: record.title, description: record.description, state: record.state } if rendering_app hash[:rendering_app] = rendering_app end [:need_id, :section, :indexable_content, :paths, :prefixes].each do |attr_name| if record.respond_to? attr_name hash[attr_name] = record.send(attr_name) end end hash end |
#register(record) ⇒ Object
record should respond to #slug and #title, or override #record_to_artefact
39 40 41 |
# File 'lib/gds_api/panopticon/registerer.rb', line 39 def register(record) register_artefact(record_to_artefact(record)) end |