Class: Ptero::Generator::ConfigGenerator

Inherits:
PHPGenerator show all
Defined in:
lib/ptero/generators/configgenerator.rb

Overview

Generator for the config.php file

Instance Attribute Summary collapse

Attributes inherited from Ptero::Generator

#app, #dir, #name

Instance Method Summary collapse

Methods inherited from PHPGenerator

#extension

Methods inherited from Ptero::Generator

const_missing, #content, #content_params, #extension, #filename, #generate, #generated?, #location, #reload, #remove, #template_path, #to_s, #type

Constructor Details

#initialize(options = {}) ⇒ ConfigGenerator

Automatically with name “config”. Pass a hash of mappings to be included in the config file

Parameters:

  • options (Hash) (defaults to: {})

    a mapping of keys and values to be included in the config.php file



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/ptero/generators/configgenerator.rb', line 12

def initialize(options={})
  super 'config'
  @options = options
  
  # Defaults
  @options[:templates_path] ||= 'views'
  @options[:controllers_path] ||= 'php/controllers'
  @options[:models_path] ||= 'php/models'
  
  @options[:database] ||= {
    name: 'database-name',
    user: 'username',
    password: 'password',
    server: 'localhost'
  }
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



29
30
31
# File 'lib/ptero/generators/configgenerator.rb', line 29

def options
  @options
end

Instance Method Details

#pathString

Returns “config”.

Returns:

  • (String)

    “config”



31
32
33
# File 'lib/ptero/generators/configgenerator.rb', line 31

def path
  "config"
end