diff options
author | Marius Balteanu <marius.balteanu@zitec.com> | 2023-12-22 02:13:32 +0000 |
---|---|---|
committer | Marius Balteanu <marius.balteanu@zitec.com> | 2023-12-22 02:13:32 +0000 |
commit | 73ffd58bfaf9bfb0a8dab3693336f9b349acab85 (patch) | |
tree | 7fcb7d3725c4c9bc46cbb7402f3c6d6e2080f5e7 /lib | |
parent | 002187d8b618e01a1427dca7d1f120449dcb560f (diff) | |
download | redmine-73ffd58bfaf9bfb0a8dab3693336f9b349acab85.tar.gz redmine-73ffd58bfaf9bfb0a8dab3693336f9b349acab85.zip |
Merge r22551 from trunk to 5.1-stable (#39862).
git-svn-id: https://svn.redmine.org/redmine/branches/5.1-stable@22552 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib')
-rw-r--r-- | lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb b/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb index 4a069980d..9c09a7870 100644 --- a/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb +++ b/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb @@ -20,6 +20,30 @@ module Redmine module Acts module Attachable + + class ObjectTypeConstraint + cattr_accessor :object_types + + self.object_types = Concurrent::Set.new(%w[ + issues versions news messages wiki_pages projects documents journals + ]) + + class << self + def matches?(request) + request.path_parameters[:object_type] =~ param_expression + end + + def register_object_type(type) + object_types << type + @param_expression = nil + end + + def param_expression + @param_expression ||= Regexp.new("^(#{object_types.join("|")})$") + end + end + end + def self.included(base) base.extend ClassMethods end |