diff --git a/Gemfile b/Gemfile index 10deeda..4c116e2 100644 --- a/Gemfile +++ b/Gemfile @@ -26,6 +26,8 @@ gem "stimulus-rails" gem 'tailwindcss-rails' +gem 'active_decorator' + # Use Redis adapter to run Action Cable in production # gem "redis", ">= 4.0.1" diff --git a/Gemfile.lock b/Gemfile.lock index b3f2dea..c4d225a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -44,6 +44,8 @@ GEM erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) + active_decorator (1.5.1) + activesupport activejob (8.0.3) activesupport (= 8.0.3) globalid (>= 0.3.6) @@ -347,6 +349,7 @@ PLATFORMS x86_64-linux-musl DEPENDENCIES + active_decorator aws-sdk-s3 (~> 1) bootsnap brakeman diff --git a/app/decorators/message_decorator.rb b/app/decorators/message_decorator.rb new file mode 100644 index 0000000..51f008c --- /dev/null +++ b/app/decorators/message_decorator.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +module MessageDecorator + def from + super&.gsub(/@[a-zA-Z.\-]+/, '@...') + end +end diff --git a/test/decorators/message_decorator_test.rb b/test/decorators/message_decorator_test.rb new file mode 100644 index 0000000..fee9e3a --- /dev/null +++ b/test/decorators/message_decorator_test.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require 'test_helper' + +class MessageDecoratorTest < ActiveSupport::TestCase + def setup + @message = Message.new.extend MessageDecorator + end + + # test "the truth" do + # assert true + # end +end