Class: Plangrade::Resources::Notice

Inherits:
Base
  • Object
show all
Defined in:
lib/plangrade/resources/notice.rb

Instance Attribute Summary

Attributes inherited from Base

#attrs, #id

Class Method Summary collapse

Methods inherited from Base

#api_handler, #base_name, base_name, #changes, #delete!, fetch, get, identity_map, #initialize, #load!, #loaded?, model_attributes, #modified?, #new_record?, #persisted?, #reload!, #save

Methods included from ApiHandler

#api_handler, #establish_api_handler

Constructor Details

This class inherits a constructor from Plangrade::Resources::Base

Class Method Details

.all(company_id) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/plangrade/resources/notice.rb', line 7

def self.all(company_id)
  result = api_handler.all_notices(company_id)
  parsed_result = JSON.parse(result.body)
  notices ||= begin
    parsed_result.map do |notice|
      new(:id => notice["id"], :name => notice["name"], :plan_name => notice["plan_name"], :link => notice["link"], :created_at => notice["created_at"])
    end
  end
  notices
end