Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slight code re-organization #49

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jaredhales
Copy link

The current organization of this gem makes it difficult to customize the behavior of this gem because it contains explicit references to fully qualified method: UnobtrusiveFlash::ControllerMixin.append_flash_to_cookie (which we had a need to tweak slightly).

I reorganized to make this unneeded and also to follow a common module pattern in the ruby community. This change was beneficial to my team and I suspect might be appreciated by others. It allowed us to easily override methods as needed and the code remains easily testable.

The current organization of this gem makes it difficult to customize the behavior of this gem because it contains explicit references to fully qualified method: `UnobtrusiveFlash::ControllerMixin.append_flash_to_cookie` (which we had a need to tweak slightly).

I reorganized to make this unneeded and also to follow a common module pattern in the ruby community. This change was beneficial to my team and I suspect might be appreciated by others. It allowed us to easily override methods as needed and the code remains easily testable.
@@ -37,7 +41,9 @@ def unobtrusive_flash_keys
[:notice, :alert, :error, :success, :warning]
end

class << self
module ClassMethods
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do wonder why these even need to class methods as opposed to making all of these instance methods (testing purposes I suppose?). We could simplify this more by making these instance methods and using the extend self pattern.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant