Class: Uploadcare::Rails::Group
- Inherits:
-
Entity::Group
- Object
- Entity::Group
- Uploadcare::Rails::Group
show all
- Includes:
- Objects::Loadable
- Defined in:
- lib/uploadcare/rails/objects/group.rb
Overview
A wrapper class that for Uploadcare::Group object. Allows caching loaded groups and has methods for Rails model attributes
Instance Method Summary
collapse
#cache_expires_in, #cache_key, #caching_enabled?, #update_attrs, #uploadcare_configuration
Instance Method Details
#file_urls ⇒ Object
28
29
30
31
32
|
# File 'lib/uploadcare/rails/objects/group.rb', line 28
def file_urls
map_file_urls do |index|
group_file_url(index)
end
end
|
#load ⇒ Object
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/uploadcare/rails/objects/group.rb', line 42
def load
group_info = if caching_enabled?
::Rails.cache.fetch(cache_key, expires_in: cache_expires_in) do
request_group_info_from_api
end
else
request_group_info_from_api
end
update_attrs(group_info)
end
|
#loaded? ⇒ Boolean
53
54
55
|
# File 'lib/uploadcare/rails/objects/group.rb', line 53
def loaded?
datetime_created.present?
end
|
#store ⇒ Object
34
35
36
|
# File 'lib/uploadcare/rails/objects/group.rb', line 34
def store
Uploadcare::GroupApi.store_group(id)
end
|
#to_s ⇒ Object
38
39
40
|
# File 'lib/uploadcare/rails/objects/group.rb', line 38
def to_s
cdn_url
end
|
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/uploadcare/rails/objects/group.rb', line 16
def transform_file_urls(
transformations,
transformator_class = Uploadcare::Rails::Transformations::ImageTransformations
)
return if cdn_url.blank?
transformations_query = transformator_class.new(transformations).call if transformations.present?
map_file_urls do |index|
[group_file_url(index), transformations_query].compact.join('-')
end
end
|