Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Real-world Functional Ruby

Tim Riley
October 12, 2017

Real-world Functional Ruby

RubyConf Malaysia 2017

Tim Riley

October 12, 2017
Tweet

More Decks by Tim Riley

Other Decks in Technology

Transcript

  1. !

  2. # Initialize once import = ImportProducts.new( download_feed: download, product_repo: repo,

    ) # Reuse many times import.(:books_feed) import.(:dvds_feed)
  3. class Product attr_reader :title, :isbn def initialize(**attrs) @title = attrs[:title]

    @isbn = attrs[:isbn] end def slug "#{to_slug(title)}-#{isbn}" end end
  4. class Product attr_reader :title, :isbn def initialize(**attrs) @title = attrs[:title]

    @isbn = attrs[:isbn] end def slug "#{to_slug(title)}-#{isbn}" end end
  5. Real developers hate him! He’s idealistic He’s making too many

    .rb files He found a #method to build better apps. Learn the one WEIRD trick to his stunning results! GET FUNCTIONAL NOW
  6. . ├── Gemfile ├── README.md ├── Rakefile ├── apps │

    └── main │ ├── lib │ │ └── main │ │ └── views │ │ └── welcome.rb │ ├── system │ │ ├── boot │ │ │ └── view.rb │ │ ├── boot.rb │ │ └── main │ │ ├── application.rb │ │ ├── container.rb │ │ ├── import.rb │ │ ├── transactions.rb │ │ ├── view_context.rb │ │ └── view_controller.rb
  7. │ │ └── relations │ └── types.rb ├── log ├──

    spec │ ├── app_helper.rb │ ├── db_helper.rb │ ├── spec_helper.rb │ └── support │ ├── db │ │ └── test_factories.rb │ └── test_helpers.rb └── system ├── blog │ ├── application.rb │ ├── container.rb │ ├── import.rb │ └── settings.rb ├── boot │ └── rom.rb └── boot.rb 28 directories, 37 files