Module: Easy311::Rails
- Defined in:
- lib/easy311/rails.rb
Constant Summary collapse
- CACHE_KEY =
'easy311_services'
Class Method Summary collapse
- .all_services ⇒ Object
- .api_wrapper ⇒ Object
- .config_path ⇒ Object
- .load_all_services! ⇒ Object
- .load_config ⇒ Object
Class Method Details
.all_services ⇒ Object
21 22 23 |
# File 'lib/easy311/rails.rb', line 21 def self.all_services ::Rails.cache.read(CACHE_KEY) || load_all_services! end |
.api_wrapper ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/easy311/rails.rb', line 25 def self.api_wrapper api_config = load_config url = api_config['url'] jurisdiction_id = api_config['jurisdiction_id'] api_key = api_config['apikey'] ApiWrapper.from_url(url, api_key, jurisdiction_id) end |
.config_path ⇒ Object
6 7 8 |
# File 'lib/easy311/rails.rb', line 6 def self.config_path "#{::Rails.root}/config/easy311.yml" end |
.load_all_services! ⇒ Object
14 15 16 17 18 19 |
# File 'lib/easy311/rails.rb', line 14 def self.load_all_services! api_wrapper = self.api_wrapper services = api_wrapper.services_with_attrs ::Rails.cache.write CACHE_KEY, services end |
.load_config ⇒ Object
10 11 12 |
# File 'lib/easy311/rails.rb', line 10 def self.load_config YAML.load(ERB.new(IO.read(config_path)).result) end |