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

Building Extensions - best practises

Peter Berkenbosch
February 27, 2014
53

Building Extensions - best practises

SpreeConf 2014 Lightning talk.

Peter Berkenbosch

February 27, 2014
Tweet

Transcript

  1. Unix philosophy building short, simple, clear, modular, and extendable code

    that can be easily maintained and repurposed by developers other than its creators.
  2. OOP

  3. module SpreeSales! class Engine < Rails::Engine! require 'spree/core'! isolate_namespace Spree!

    engine_name 'spree_sales'! ! # use rspec for tests! config.generators do |g|! g.test_framework :rspec! end! ! def self.activate! Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')) do |c|! Rails.configuration.cache_classes ? require(c) : load(c)! end! end! ! config.to_prepare &method(:activate).to_proc! end! end
  4. # Requires factories defined in spree_core! require 'spree/testing_support/factories'! require 'spree/testing_support/controller_requests'!

    require 'spree/testing_support/authorization_helpers'! require 'spree/testing_support/url_helpers'