Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This seems like a good place to use monkeypatching, using modules inside lib/.</p> <p>Say you want a <code>Client</code> resource. You start by putting the "common" (shared by all dificulty levels) functionality on the default files (Alternatively, you can put the "easy" implementation there)</p> <pre><code># /app/models/client.rb class Client &lt; ActiveRecord::Base def foo # default and/or "easy" implementation end end # /app/controllers/client_controller.rb class ClientController &lt; ApplicationController def bar # default and/or "easy" implementation end end </code></pre> <p>Monkeypatches for <code>client.rb</code> and <code>client_controller.rb</code> on the 'medium' difficulty could be placed inside the <code>/lib/medium</code> module :</p> <pre><code># /lib/medium/models/client_patch.rb class Client def foo # medium implementation end end # /lib/medium/controllers/client_controller_patch.rb class ClientController def bar # medium implementation end end </code></pre> <p>You will need a file that includes all those patches depending on the difficulty. A simple solution would be a simple file like this:</p> <pre><code># /lib/medium.rb require 'medium/models/client_patch' ... require 'medium/controllers/client_controller_patch' </code></pre> <p>So you can require it from an initializer:</p> <pre><code># /config/initializers/difficulty.rb # require 'easy' require 'medium' # require 'difficult' </code></pre> <p>You can then launch three different instances of the application, one on easy, one on medium and one on difficult. The code will be shared, with the exception of the difficulty.rb initializer (and I'll assume that you will also need different configuration files for the database, log files etc).</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload