Class: Uploadcare::Rails::Group
- Inherits:
-
Api::Group
- Object
- Api::Group
- Uploadcare::Rails::Group
- Defined in:
- lib/uploadcare/rails/objects/group.rb
Instance Method Summary collapse
- #as_json(_options = {}) ⇒ Object
- #cache_data ⇒ Object
- #load_data ⇒ Object (also: #load)
- #load_data! ⇒ Object (also: #load!)
- #marshal_dump ⇒ Object
- #to_json ⇒ Object
-
#to_s ⇒ Object
override default to string method for group we just will return the uuid.
-
#urls(operations = nil) ⇒ Object
warkaround to build images urls without API request builds array of image urls including operations.
Instance Method Details
#as_json(_options = {}) ⇒ Object
56 57 58 |
# File 'lib/uploadcare/rails/objects/group.rb', line 56 def as_json( = {}) marshal_dump end |
#cache_data ⇒ Object
34 35 36 37 38 |
# File 'lib/uploadcare/rails/objects/group.rb', line 34 def cache_data return unless UPLOADCARE_SETTINGS.cache_groups ::Rails.cache.write(cdn_url, marshal_dump) self end |
#load_data ⇒ Object Also known as: load
19 20 21 22 |
# File 'lib/uploadcare/rails/objects/group.rb', line 19 def load_data load_data! unless is_loaded? self end |
#load_data! ⇒ Object Also known as: load!
26 27 28 29 30 |
# File 'lib/uploadcare/rails/objects/group.rb', line 26 def load_data! set_data(@api.get("/groups/#{ uuid }/")) cache_data self end |
#marshal_dump ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/uploadcare/rails/objects/group.rb', line 40 def marshal_dump table = @table.deep_dup.stringify_keys! if table['files'] table['files'].map! do |file| file.marshal_dump.stringify_keys end end table end |
#to_json ⇒ Object
52 53 54 |
# File 'lib/uploadcare/rails/objects/group.rb', line 52 def to_json marshal_dump end |
#to_s ⇒ Object
override default to string method for group we just will return the uuid
62 63 64 |
# File 'lib/uploadcare/rails/objects/group.rb', line 62 def to_s uuid end |
#urls(operations = nil) ⇒ Object
warkaround to build images urls without API request builds array of image urls including operations
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/uploadcare/rails/objects/group.rb', line 7 def urls(operations = nil) (0..files_count.to_i - 1).to_a.map do |i| [ @api.[:static_url_base], uuid, 'nth', i, Operations.new(operations).to_s ].join('/') end end |