rhino_project_core 0.22.0.beta.7 → 0.22.0.beta.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ff72f569e06461388653d0301fc523626fb2d738bce4cee23eeb097790a89948
4
- data.tar.gz: 0b742c43b55c24367a7294f24c273b9d6a75719368d2a9163734110b22d74afb
3
+ metadata.gz: bf0667213326e7eae155287594df1c21730b2023231ee48c4273937e7066eb67
4
+ data.tar.gz: 1d05e4edc02af9921a5f0e715780cffc0b6c0c473a07258bb45e02955a968407
5
5
  SHA512:
6
- metadata.gz: 5d043f55d66eb179c98da96d004b5d06ee7c17e2e67d39b046734d0f08831022c34294eae5809dc49d17900883ad267e05150c2176e512692651019e4a98b749
7
- data.tar.gz: 666c16e6a708464cd628814ade3ba3d451b8490abf1a6450e7dad80b7544a000a4a07a264e8df1b3d2a258da8f40b5a5e4333e5c8a0cfcde979af989c506a089
6
+ metadata.gz: e9ded280a6c674e1e76185f360a9810572e60365ee24426043effc245cc6f97d5962d4b2f81d75aa13a644894e920bf6b3e7ba12ee680783d53b0abe8ed0f062
7
+ data.tar.gz: 30fe85862e8e2d5526e4ecb233c403cc5b8cea123975b73a78ed1880f542b600c39ad46e74787fc246b157f21e4b1aaf54a15dac4e2cb817d22ec9815baa1a22
@@ -11,15 +11,30 @@ module Rhino
11
11
  included do
12
12
  attribute :url
13
13
  attribute :url_attachment
14
+ attribute :variants, :json, default: {}
14
15
 
15
16
  rhino_policy :active_storage_attachment
16
17
 
17
- def url
18
- Rails.application.routes.url_helpers.rails_blob_url(self, only_path: false)
18
+ def url(attachment = self, **options)
19
+ Rails.application.routes.url_helpers.rails_blob_url(attachment, only_path: false, **options)
19
20
  end
20
21
 
21
- def url_attachment
22
- Rails.application.routes.url_helpers.rails_blob_url(self, only_path: false, disposition: :attachment)
22
+ def url_attachment(attachment = self)
23
+ url(attachment, disposition: :attachment)
24
+ end
25
+
26
+ def variants
27
+ # Not everything may be processed into a variant based on mime type
28
+ return unless variable?
29
+
30
+ record.attachment_reflections[self.name]&.named_variants&.keys&.index_with do |v|
31
+ variant = variant(v)
32
+
33
+ {
34
+ url: url(variant),
35
+ url_attachment: url_attachment(variant)
36
+ }
37
+ end
23
38
  end
24
39
 
25
40
  def display_name
@@ -29,7 +44,7 @@ module Rhino
29
44
 
30
45
  class_methods do
31
46
  def readable_properties
32
- super + ["signed_id"]
47
+ super + [ "variants", "signed_id"]
33
48
  end
34
49
  end
35
50
 
data/lib/rhino/version.rb CHANGED
@@ -10,7 +10,7 @@ module Rhino
10
10
  MAJOR = 0
11
11
  MINOR = 22
12
12
  TINY = 0
13
- PRE = "beta.7"
13
+ PRE = "beta.9"
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rhino_project_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.22.0.beta.7
4
+ version: 0.22.0.beta.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - JP Rosevear
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-12-07 00:00:00.000000000 Z
11
+ date: 2024-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails