Sha256: 2dd722171f35855155d0e4fb2b0de2396243f8c8e438f06a625a4a3941400773

Contents?: true

Size: 1.63 KB

Versions: 8

Compression:

Stored size: 1.63 KB

Contents

* Place your initialization code in a file named after the environment


  There are often multiple environment configurations for multiple databases in the configuration file, so you can use the
  method here to put the initialization code of different environments in different files to avoid conflicts.

  Let's say you have 4 database environments configured in the configuration file:

  - apollo.dev
  - apollo.prod
  - space.dev
  - space.prod


  Then you can create the following file in the =~/.arql.d/= directory:

  - apollo.rb
  - space.rb


  Place the initialization code for the Apollo project =apollo.rb= in the file; Place the initialization code for the
  space project =space.rb= in the file.


  Then write the following code in the =~/.arql.d/init.eb= file:

  #+begin_src ruby
    Dir.glob(File.dirname(__FILE__) + '/*.rb').each do |f|
      Arql::App.instance.definitions.each do |env, definition|
        if env.starts_with?(File.basename(f, '.rb'))
          load(f, definition.namespace_module)
        end
      end
    end
  #+end_src


  In this way, =arql -e apollo.prod= when or is executed, the initialization =apollo.rb= code in the file is loaded, and
  =arql -e space.prod= when or is executed =arql -e apollo.dev= =arql -e space.dev= , the initialization code in the file
  is loaded =space.rb=  .


  =apollo.rb= The code in the =space.rb= or file will be executed under the corresponding Namespace Module:

  #+begin_src ruby
    class Astronaut
      has_many :missions
    end
  #+end_src

  Equivalent to:

  #+begin_src ruby
    module Apollo
      class Astronaut
        has_many :missions
      end
    end
  #+end_src

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
arql-0.4.11 initializer-structure.org
arql-0.4.10 initializer-structure.org
arql-0.4.8 initializer-structure.org
arql-0.4.7 initializer-structure.org
arql-0.4.6 initializer-structure.org
arql-0.4.3 initializer-structure.org
arql-0.4.2 initializer-structure.org
arql-0.4.1 initializer-structure.org