Class: ActiveCachedResource::Collection
- Inherits:
-
ActiveResource::Collection
- Object
- ActiveResource::Collection
- ActiveCachedResource::Collection
- Defined in:
- lib/active_cached_resource/collection.rb
Instance Attribute Summary
Attributes inherited from ActiveResource::Collection
#from, #path_params, #prefix_options, #query_params, #resource_class
Class Method Summary collapse
-
.persisted_attribute(*args) ⇒ void
This method dynamically creates accessor methods for the specified attributes and adds them to a list of virtual persisted attributes to keep track of attributes that should be persisted to cache.
Instance Method Summary collapse
-
#reload ⇒ Object
Reload the collection by re-fetching the resources from the API.
- #virtual_persistable_attributes ⇒ Object
Methods inherited from ActiveResource::Collection
#call, #each, #first_or_create, #first_or_initialize, #initialize, none, #parse_response, #requested?, #where
Constructor Details
This class inherits a constructor from ActiveResource::Collection
Class Method Details
.persisted_attribute(*args) ⇒ void
This method returns an undefined value.
This method dynamically creates accessor methods for the specified attributes and adds them to a list of virtual persisted attributes to keep track of attributes that should be persisted to cache.
11 12 13 14 |
# File 'lib/active_cached_resource/collection.rb', line 11 def self.persisted_attribute(*args) attr_accessor(*args) self.virtual_persisted_attributes += args end |
Instance Method Details
#reload ⇒ Object
Reload the collection by re-fetching the resources from the API.
25 26 27 28 |
# File 'lib/active_cached_resource/collection.rb', line 25 def reload query_params[Constants::RELOAD_PARAM] = true super end |
#virtual_persistable_attributes ⇒ Object
16 17 18 19 20 |
# File 'lib/active_cached_resource/collection.rb', line 16 def virtual_persistable_attributes self.class.virtual_persisted_attributes.each_with_object({}) do |attribute, hash| hash[attribute] = public_send(attribute) end end |