Last active
January 4, 2016 15:19
-
-
Save laser/8640296 to your computer and use it in GitHub Desktop.
unnecessarily introducing mutable state
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class RssImporter | |
| attr_writer :articles | |
| attr_reader :result | |
| def import | |
| @result = articles.map do |article| | |
| RssContent.create { url: article.url, text: article.body } | |
| end | |
| end | |
| end | |
| # consuming the RssImporter... | |
| importer = RssImporter.new | |
| importer.articles = a_bunch_of_rss_content | |
| importer.import | |
| imported = importer.result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment