aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/CHANGELOG.md
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2013-12-17 02:31:57 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2013-12-17 02:31:57 -0700
commit1eee0ca6de975b42524105a59e0521d18b38ab81 (patch)
treeb3f3e6cabf4abde34943c65caef263b914d96310 /activesupport/CHANGELOG.md
parentc28d0f2031d31aeb5289b73acbb5c1adb7bd71d4 (diff)
downloadrails-1eee0ca6de975b42524105a59e0521d18b38ab81.tar.gz
rails-1eee0ca6de975b42524105a59e0521d18b38ab81.tar.bz2
rails-1eee0ca6de975b42524105a59e0521d18b38ab81.zip
Introduce Module#concerning
A natural, low-ceremony way to separate responsibilities within a class. Imported from https://github.com/37signals/concerning#readme
Diffstat (limited to 'activesupport/CHANGELOG.md')
-rw-r--r--activesupport/CHANGELOG.md47
1 files changed, 47 insertions, 0 deletions
diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md
index 994e44db00..1945572bf7 100644
--- a/activesupport/CHANGELOG.md
+++ b/activesupport/CHANGELOG.md
@@ -1,3 +1,50 @@
+* Introduce Module#concerning: a natural, low-ceremony way to separate
+ responsibilities within a class.
+
+ Imported from https://github.com/37signals/concerning#readme
+
+ class Todo < ActiveRecord::Base
+ concerning :EventTracking do
+ included do
+ has_many :events
+ end
+
+ def latest_event
+ ...
+ end
+
+ private
+ def some_internal_method
+ ...
+ end
+ end
+
+ concerning :Trashable do
+ def trashed?
+ ...
+ end
+
+ def latest_event
+ super some_option: true
+ end
+ end
+ end
+
+ is equivalent to defining these modules inline, extending them into
+ concerns, then mixing them in to the class.
+
+ Inline concerns tame "junk drawer" classes that intersperse many unrelated
+ class-level declarations, public instance methods, and private
+ implementation. Coalesce related bits and give them definition.
+ These are a stepping stone toward future growth & refactoring.
+
+ When to move on from an inline concern:
+ * Encapsulating state? Extract collaborator object.
+ * Encompassing more public behavior or implementation? Move to separate file.
+ * Sharing behavior among classes? Move to separate file.
+
+ *Jeremy Kemper*
+
* Fix file descriptor being leaked on each call to `Kernel.silence_stream`.
*Mario Visic*