Class: GovKit::OpenStatesResource
- Defined in:
- lib/gov_kit/open_states.rb
Overview
Parent class for OpenStates resources See openstates.sunlightlabs.com/api/
Direct Known Subclasses
GovKit::OpenStates::Action, GovKit::OpenStates::Address, GovKit::OpenStates::Bill, GovKit::OpenStates::Committee, GovKit::OpenStates::Legislator, GovKit::OpenStates::Role, GovKit::OpenStates::Source, GovKit::OpenStates::Sponsor, GovKit::OpenStates::State, GovKit::OpenStates::Version, GovKit::OpenStates::Vote
Instance Attribute Summary
Attributes inherited from Resource
Class Method Summary collapse
-
.get_uri(uri, options = {}) ⇒ Object
Do a GET query, with optional parameters.
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, ={}) begin response = get(uri, ) result = parse(response) rescue ResourceNotFound return [] end result end |