simple_form_extension 1.4.17 → 1.5.0

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
- SHA1:
3
- metadata.gz: '0880fda87e213f7de641ecfc0ca1a99537e4ca86'
4
- data.tar.gz: 19de2b75fef0391593d598dc10fddfdf44c126f1
2
+ SHA256:
3
+ metadata.gz: 38aa08ea4a8cf92f6fc0cc37e25626842ae034d35244b917f6043d3da61ec28f
4
+ data.tar.gz: 695288388ad82f16580b7bfd1bf04590e20d070fb82d1595e5c23ad732a7331a
5
5
  SHA512:
6
- metadata.gz: b9556a62fa16ae35cfb5e7ee041a40b3062414f77949051b4d467421c293a48d9bbeb364cf3de6a30cfea4bf448367ba99dee3f0453e231bc1221bd2c97a5e52
7
- data.tar.gz: '004581a2f91da9b365764f4423021bc445654413db2d1afeebfdc684ac27395c1ba1593c31eda8cb42c7e4497451f6fb9b97095d44cb09244a249677161c3b6b'
6
+ metadata.gz: c06e4eaa4ff32484bd0dea6e9fa5727dde895796d10a9a9996eb7cd8b18c953619ee16b0b2ff85250c6843353934ca3e4b57886ad49884d64d071f7a0f2b3aa6
7
+ data.tar.gz: e6a67846e389e65734d7cff721f692db9ddd3601b298af8c0faa443ad90a1d4acc697870689ac87be9d1078f9fd65782681f3fa941de53ab948c94b4f42f9702
data/README.md CHANGED
@@ -142,7 +142,7 @@ You can customize the name of the setter that will be called with the
142
142
  #### :selectize
143
143
 
144
144
  The selectize field allows you to create a powerful select field using the
145
- [Selectize](https://brianreavis.github.io/selectize.js/) javascript plugin.
145
+ [Selectize](https://selectize.github.io/selectize.js/) javascript plugin.
146
146
 
147
147
  ```ruby
148
148
  = form.input :items, as: :selectize, collection: Item.all
@@ -26,9 +26,10 @@ module SimpleFormExtension
26
26
  end
27
27
 
28
28
  def existing_file_name
29
- if object.try(:"#{ attribute_name }?")
29
+ if paperclip_attachment_attached?
30
30
  object.send(:"#{ attribute_name }_file_name").html_safe
31
- elsif (attachment = object.try(attribute_name)).try(:attached?)
31
+ elsif activestorage_attachment_attached?
32
+ attachment = object.send(attribute_name)
32
33
  attachment.filename.to_s
33
34
  end
34
35
  end
@@ -47,16 +48,25 @@ module SimpleFormExtension
47
48
  end
48
49
 
49
50
  def file_exists?
50
- @file_exists ||= object.try(:"#{ attribute_name }?") ||
51
- object.try(attribute_name).try(:attached?)
51
+ @file_exists ||= paperclip_attachment_attached? || activestorage_attachment_attached?
52
52
  end
53
53
 
54
54
  def file_url
55
- if object.try(:"#{ attribute_name }?")
55
+ if paperclip_attachment_attached?
56
56
  object.send(attribute_name)
57
- elsif object.try(attribute_name).try(:attached?)
58
- object.try(attribute_name).try(:service_url)
57
+ elsif activestorage_attachment_attached?
58
+ object.send(attribute_name).try(:service_url) || object.send(attribute_name).try(:url)
59
59
  end
60
60
  end
61
+
62
+ def paperclip_attachment_attached?
63
+ @paperclip_attachment_attached ||= object.try(:"#{ attribute_name }?")
64
+ end
65
+
66
+ def activestorage_attachment_attached?
67
+ @activestorage_attachment_attached ||=
68
+ object.try(attribute_name).try(:attached?) &&
69
+ object.try(attribute_name).blob
70
+ end
61
71
  end
62
72
  end
@@ -70,13 +70,13 @@ module SimpleFormExtension
70
70
  # preview thumbnail
71
71
  #
72
72
  def file_url
73
- if object.try(:"#{ attribute_name }?")
73
+ if paperclip_attachment_attached?
74
74
  object.send(attribute_name).url(image_style)
75
- elsif (attachment = object.try(attribute_name)).try(:attached?)
76
- if attachment.variable?
77
- attachment.variant(resize: "400x150>")
78
- elsif attachment.previewable?
79
- attachment.preview(resize: "400x150>")
75
+ elsif activestorage_attachment_attached?
76
+ attachment = object.send(attribute_name)
77
+
78
+ if attachment.representable?
79
+ attachment.representation(resize: "400x150>")
80
80
  else
81
81
  attachment.service_url
82
82
  end
@@ -170,7 +170,8 @@ module SimpleFormExtension
170
170
  end
171
171
 
172
172
  def enum?
173
- object_class.defined_enums.key?(attribute_name.to_s)
173
+ object_class.respond_to?(:defined_enums) &&
174
+ object_class.defined_enums.key?(attribute_name.to_s)
174
175
  end
175
176
 
176
177
  def enum_options
@@ -1,3 +1,3 @@
1
1
  module SimpleFormExtension
2
- VERSION = "1.4.17"
2
+ VERSION = '1.5.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_form_extension
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.17
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Glyph-fr
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-12 00:00:00.000000000 Z
11
+ date: 2023-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -163,7 +163,7 @@ homepage: http://www.glyph.fr
163
163
  licenses:
164
164
  - MIT
165
165
  metadata: {}
166
- post_install_message:
166
+ post_install_message:
167
167
  rdoc_options: []
168
168
  require_paths:
169
169
  - lib
@@ -178,9 +178,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
178
178
  - !ruby/object:Gem::Version
179
179
  version: '0'
180
180
  requirements: []
181
- rubyforge_project:
182
- rubygems_version: 2.6.11
183
- signing_key:
181
+ rubygems_version: 3.3.7
182
+ signing_key:
184
183
  specification_version: 4
185
184
  summary: This gems adds custom common input types to simple form.
186
185
  test_files: []