Class: Fluxx::Resource
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- Fluxx::Resource
- Extended by:
- HTTP::RestClient::CRUD, HTTP::RestClient::DSL
- Defined in:
- lib/fluxx/resource.rb
Overview
Base endpoint resources class
Direct Known Subclasses
Constant Summary collapse
- PAGINATION_FIELDS =
[ 'total_pages', 'total_entries', 'current_page', 'per_page' ]
Class Method Summary collapse
-
.endpoint(value = nil) ⇒ String
Defines the client endpoint, thread-safe.
-
.objectify(payload) ⇒ Object
Resource constructor wrapper.
-
.request(*args) ⇒ HTTP::Response
Updated request handler with the auto-refreshing token authentication.
Class Method Details
.endpoint(value = nil) ⇒ String
Defines the client endpoint, thread-safe
24 25 26 27 28 |
# File 'lib/fluxx/resource.rb', line 24 def self.endpoint(value = nil) return super(value) unless value.nil? Thread.current.thread_variable_get(:FLUXX_INSTANCE_URL) || super end |
.objectify(payload) ⇒ Object
Resource constructor wrapper
43 44 45 46 47 48 49 |
# File 'lib/fluxx/resource.rb', line 43 def self.objectify(payload) filtered = payload.reject { |key, _| PAGINATION_FIELDS.include?(key) } data = filtered.values.first if filtered.is_a?(Hash) && filtered.size == 1 data = data.values.first if data.is_a?(Hash) && data.size == 1 super(data || payload) end |