Skip to content

Instantly share code, notes, and snippets.

@laser
Last active January 4, 2016 15:19
Show Gist options
  • Select an option

  • Save laser/8640296 to your computer and use it in GitHub Desktop.

Select an option

Save laser/8640296 to your computer and use it in GitHub Desktop.
unnecessarily introducing mutable state
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