Class: FrederickAPI::V2::Resource
- Inherits:
-
JsonApiClient::Resource
- Object
- JsonApiClient::Resource
- FrederickAPI::V2::Resource
show all
- Includes:
- Helpers::HasMany
- Defined in:
- lib/frederick_api/v2/resource.rb
Overview
Class from which Frederick V2 Resources inherit Inherits functionality from JsonApiClient::Resource
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(params = {}) ⇒ Resource
Returns a new instance of Resource.
16
17
18
19
|
# File 'lib/frederick_api/v2/resource.rb', line 16
def initialize(params = {})
self. = self.class.
super
end
|
Instance Attribute Details
Returns the value of attribute custom_headers.
14
15
16
|
# File 'lib/frederick_api/v2/resource.rb', line 14
def
end
|
Class Method Details
47
48
49
|
# File 'lib/frederick_api/v2/resource.rb', line 47
def self.
Thread.current['frederick_api_header_store'] ||= {}
end
|
.all_records ⇒ Object
25
26
27
|
# File 'lib/frederick_api/v2/resource.rb', line 25
def self.all_records
self.all.pages.all_records
end
|
43
44
45
|
# File 'lib/frederick_api/v2/resource.rb', line 43
def self.
super.merge(x_api_key: top_level_namespace.config.api_key)
end
|
.site ⇒ Object
33
34
35
|
# File 'lib/frederick_api/v2/resource.rb', line 33
def self.site
"#{top_level_namespace.config.base_url}/v2/"
end
|
.top_level_namespace ⇒ Object
29
30
31
|
# File 'lib/frederick_api/v2/resource.rb', line 29
def self.top_level_namespace
@top_level_namespace ||= self.to_s.split('::').first.constantize
end
|
.with_access_token(token) ⇒ Object
37
38
39
40
41
|
# File 'lib/frederick_api/v2/resource.rb', line 37
def self.with_access_token(token)
(authorization: "Bearer #{token}") do
yield
end
end
|
Instance Method Details
#has_errors? ⇒ Boolean
21
22
23
|
# File 'lib/frederick_api/v2/resource.rb', line 21
def has_errors?
self.errors.present?
end
|