Class: GovKit::OpenStatesResource

Inherits:
Resource
  • Object
show all
Defined in:
lib/gov_kit/open_states.rb

Overview

Parent class for OpenStates resources See openstates.sunlightlabs.com/api/

Instance Attribute Summary

Attributes inherited from Resource

#attributes, #raw_response

Class Method Summary collapse

Methods inherited from Resource

#initialize, instantiate, instantiate_collection, parse, #to_md5, #unload

Constructor Details

This class inherits a constructor from GovKit::Resource

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class GovKit::Resource

Class Method Details

.get_uri(uri, options = {}) ⇒ Object

Do a GET query, with optional parameters.

OpenStates returns a 404 error when a query returns nothing.

So, if a query result is a resource not found error, we return an empty set.



20
21
22
23
24
25
26
27
28
# File 'lib/gov_kit/open_states.rb', line 20

def self.get_uri(uri, options={})
  begin
    response = get(uri, options)
    result = parse(response)
  rescue ResourceNotFound
    return []
  end
  result
end