activestorage_legacy 0.1.3 → 0.2.1
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85b0639d2b85b20f642fa1f1fb81d92d4e22db9e
|
4
|
+
data.tar.gz: c6dcafff77c7d2bb01766535ebd20b6966ef4c3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2174183b2ac39ec0290117e8187d3684826fda3787aada750486510cb04ba345d4796cc41c2154c9bda35cfdb40b641ffb0238b399e2489a03ddf4d99cbe33ae
|
7
|
+
data.tar.gz: f578d46dbea611666d2e999836e8f5ab206dc8120564b690b743b377499988f5dae5b1c220c2ac527a3aa4ffa1cc244a1227b1bf1dbbbcc82d2e20d484997cd2
|
data/activestorage.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.authors = "David Heinemeier Hansson"
|
12
12
|
s.email = "david@basecamp.com"
|
13
13
|
s.summary = "Attach cloud and local files in Rails applications"
|
14
|
-
s.homepage = "https://github.com/
|
14
|
+
s.homepage = "https://github.com/iagopiimenta/activestorage_legacy"
|
15
15
|
s.license = "MIT"
|
16
16
|
|
17
17
|
s.required_ruby_version = ">= 2.2.2"
|
@@ -2,17 +2,17 @@ module ActiveStorage
|
|
2
2
|
# Temporary hack to overwrite the default file_field_tag and Form#file_field to accept a direct_upload: true option
|
3
3
|
# that then gets replaced with a data-direct-upload-url attribute with the route prefilled.
|
4
4
|
module FileFieldWithDirectUploadHelper
|
5
|
-
def file_field_tag(name, options = {})
|
6
|
-
|
7
|
-
end
|
8
|
-
|
9
|
-
def file_field(object_name, method, options = {})
|
10
|
-
|
11
|
-
end
|
12
|
-
|
13
|
-
private
|
14
|
-
|
15
|
-
|
16
|
-
|
5
|
+
# def file_field_tag(name, options = {})
|
6
|
+
# text_field_tag(name, nil, convert_direct_upload_option_to_url(options.merge(type: :file)))
|
7
|
+
# end
|
8
|
+
#
|
9
|
+
# def file_field(object_name, method, options = {})
|
10
|
+
# ActionView::Helpers::Tags::FileField.new(object_name, method, self, convert_direct_upload_option_to_url(options)).render
|
11
|
+
# end
|
12
|
+
#
|
13
|
+
# private
|
14
|
+
# def convert_direct_upload_option_to_url(options)
|
15
|
+
# options.merge('data-direct-upload-url': options.delete(:direct_upload) ? rails_direct_uploads_url : nil).compact
|
16
|
+
# end
|
17
17
|
end
|
18
18
|
end
|
@@ -5,15 +5,15 @@ require "set"
|
|
5
5
|
class Module
|
6
6
|
# Error generated by +delegate+ when a method is called on +nil+ and +allow_nil+
|
7
7
|
# option is not used.
|
8
|
-
class DelegationError < NoMethodError; end
|
8
|
+
class DelegationError < NoMethodError; end unless defined?(DelegationError)
|
9
9
|
|
10
10
|
RUBY_RESERVED_KEYWORDS = %w(__ENCODING__ __LINE__ __FILE__ alias and BEGIN begin break
|
11
11
|
case class def defined? do else elsif END end ensure false for if in module next nil
|
12
|
-
not or redo rescue retry return self super then true undef unless until when while yield)
|
13
|
-
DELEGATION_RESERVED_KEYWORDS = %w(_ arg args block)
|
12
|
+
not or redo rescue retry return self super then true undef unless until when while yield) unless defined?(RUBY_RESERVED_KEYWORDS)
|
13
|
+
DELEGATION_RESERVED_KEYWORDS = %w(_ arg args block) unless defined?(DELEGATION_RESERVED_KEYWORDS)
|
14
14
|
DELEGATION_RESERVED_METHOD_NAMES = Set.new(
|
15
15
|
RUBY_RESERVED_KEYWORDS + DELEGATION_RESERVED_KEYWORDS
|
16
|
-
).freeze
|
16
|
+
).freeze unless defined?(DELEGATION_RESERVED_METHOD_NAMES)
|
17
17
|
|
18
18
|
# When building decorators, a common pattern may emerge:
|
19
19
|
#
|
@@ -61,38 +61,40 @@ class Module
|
|
61
61
|
# delegation due to possible interference when calling
|
62
62
|
# <tt>Marshal.dump(object)</tt>, should the delegation target method
|
63
63
|
# of <tt>object</tt> add or remove instance variables.
|
64
|
-
|
65
|
-
target
|
66
|
-
|
64
|
+
unless Module.instance_methods(false).include?(:delegate_missing_to)
|
65
|
+
def delegate_missing_to(target, allow_nil: nil)
|
66
|
+
target = target.to_s
|
67
|
+
target = "self.#{target}" if DELEGATION_RESERVED_METHOD_NAMES.include?(target)
|
67
68
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
69
|
+
module_eval <<-RUBY, __FILE__, __LINE__ + 1
|
70
|
+
def respond_to_missing?(name, include_private = false)
|
71
|
+
# It may look like an oversight, but we deliberately do not pass
|
72
|
+
# +include_private+, because they do not get delegated.
|
73
|
+
|
74
|
+
return false if name == :marshal_dump || name == :_dump
|
75
|
+
#{target}.respond_to?(name) || super
|
76
|
+
end
|
77
|
+
|
78
|
+
def method_missing(method, *args, &block)
|
79
|
+
if #{target}.respond_to?(method)
|
80
|
+
#{target}.public_send(method, *args, &block)
|
81
|
+
else
|
82
|
+
begin
|
83
|
+
super
|
84
|
+
rescue NoMethodError
|
85
|
+
if #{target}.nil?
|
86
|
+
if #{allow_nil == true}
|
87
|
+
nil
|
88
|
+
else
|
89
|
+
raise DelegationError, "\#{method} delegated to #{target}, but #{target} is nil"
|
90
|
+
end
|
87
91
|
else
|
88
|
-
raise
|
92
|
+
raise
|
89
93
|
end
|
90
|
-
else
|
91
|
-
raise
|
92
94
|
end
|
93
95
|
end
|
94
96
|
end
|
95
|
-
|
96
|
-
|
97
|
+
RUBY
|
98
|
+
end
|
97
99
|
end
|
98
100
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activestorage_legacy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -191,7 +191,7 @@ files:
|
|
191
191
|
- test/test_helper.rb
|
192
192
|
- webpack.config.js
|
193
193
|
- yarn.lock
|
194
|
-
homepage: https://github.com/
|
194
|
+
homepage: https://github.com/iagopiimenta/activestorage_legacy
|
195
195
|
licenses:
|
196
196
|
- MIT
|
197
197
|
metadata: {}
|