Class: GdsApi::Panopticon

Inherits:
Base
  • Object
show all
Includes:
ExceptionHandling
Defined in:
lib/gds_api/panopticon.rb,
lib/gds_api/panopticon/registerer.rb

Defined Under Namespace

Classes: Registerer

Instance Attribute Summary

Attributes inherited from Base

#options

Instance Method Summary collapse

Methods included from ExceptionHandling

#ignoring, #ignoring_missing

Methods inherited from Base

#client, #create_client, #get_list!, #initialize, #url_for_slug

Constructor Details

This class inherits a constructor from GdsApi::Base

Instance Method Details

#allObject



9
10
11
12
13
# File 'lib/gds_api/panopticon.rb', line 9

def all
  url = base_url + '.json'
  json = get_json url
  to_ostruct json
end

#artefact_for_slug(slug, opts = {}) ⇒ Object



15
16
17
18
# File 'lib/gds_api/panopticon.rb', line 15

def artefact_for_slug(slug, opts = {})
  return nil if slug.nil? or slug == ''
  get_json(url_for_slug(slug))
end

#create_artefact(artefact) ⇒ Object



20
21
22
23
24
# File 'lib/gds_api/panopticon.rb', line 20

def create_artefact(artefact)
  ignoring GdsApi::HTTPErrorResponse do
    create_artefact! artefact
  end
end

#create_artefact!(artefact) ⇒ Object



26
27
28
# File 'lib/gds_api/panopticon.rb', line 26

def create_artefact!(artefact)
  post_json!(base_url + ".json", artefact)
end

#delete_artefact!(id_or_slug) ⇒ Object



48
49
50
# File 'lib/gds_api/panopticon.rb', line 48

def delete_artefact!(id_or_slug)
  delete_json!("#{base_url}/#{id_or_slug}.json")
end

#put_artefact(id_or_slug, artefact) ⇒ Object



30
31
32
33
34
# File 'lib/gds_api/panopticon.rb', line 30

def put_artefact(id_or_slug, artefact)
  ignoring GdsApi::HTTPErrorResponse do
    put_artefact! id_or_slug, artefact
  end
end

#put_artefact!(id_or_slug, artefact) ⇒ Object



36
37
38
# File 'lib/gds_api/panopticon.rb', line 36

def put_artefact!(id_or_slug, artefact)
  put_json!("#{base_url}/#{id_or_slug}.json", artefact)
end

#update_artefact(id_or_slug, artefact) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/gds_api/panopticon.rb', line 40

def update_artefact(id_or_slug, artefact)
  self.class.logger.warn(
    "The update_artefact method is deprecated and may be removed in a " +
    "future release. You should use put_artefact instead."
  )
  put_artefact(id_or_slug, artefact)
end