Class: Rails::Configuration::Generators

Inherits:
Object
  • Object
show all
Defined in:
lib/rails/configuration.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGenerators

Returns a new instance of Generators.



93
94
95
96
97
98
99
100
101
# File 'lib/rails/configuration.rb', line 93

def initialize
  @aliases = Hash.new { |h,k| h[k] = {} }
  @options = Hash.new { |h,k| h[k] = {} }
  @fallbacks = {}
  @templates = []
  @colorize_logging = true
  @api_only = false
  @hidden_namespaces = []
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/rails/configuration.rb', line 114

def method_missing(method, *args)
  method = method.to_s.sub(/=$/, '').to_sym

  return @options[method] if args.empty?

  if method == :rails || args.first.is_a?(Hash)
    namespace, configuration = method, args.shift
  else
    namespace, configuration = args.shift, args.shift
    namespace = namespace.to_sym if namespace.respond_to?(:to_sym)
    @options[:rails][method] = namespace
  end

  if configuration
    aliases = configuration.delete(:aliases)
    @aliases[namespace].merge!(aliases) if aliases
    @options[namespace].merge!(configuration)
  end
end

Instance Attribute Details

#aliasesObject

Returns the value of attribute aliases.



90
91
92
# File 'lib/rails/configuration.rb', line 90

def aliases
  @aliases
end

#api_onlyObject

Returns the value of attribute api_only.



90
91
92
# File 'lib/rails/configuration.rb', line 90

def api_only
  @api_only
end

#colorize_loggingObject

Returns the value of attribute colorize_logging.



90
91
92
# File 'lib/rails/configuration.rb', line 90

def colorize_logging
  @colorize_logging
end

#fallbacksObject

Returns the value of attribute fallbacks.



90
91
92
# File 'lib/rails/configuration.rb', line 90

def fallbacks
  @fallbacks
end

#hidden_namespacesObject (readonly)

Returns the value of attribute hidden_namespaces.



91
92
93
# File 'lib/rails/configuration.rb', line 91

def hidden_namespaces
  @hidden_namespaces
end

#optionsObject

Returns the value of attribute options.



90
91
92
# File 'lib/rails/configuration.rb', line 90

def options
  @options
end

#templatesObject

Returns the value of attribute templates.



90
91
92
# File 'lib/rails/configuration.rb', line 90

def templates
  @templates
end

Instance Method Details

#hide_namespace(namespace) ⇒ Object



110
111
112
# File 'lib/rails/configuration.rb', line 110

def hide_namespace(namespace)
  @hidden_namespaces << namespace
end

#initialize_copy(source) ⇒ Object



103
104
105
106
107
108
# File 'lib/rails/configuration.rb', line 103

def initialize_copy(source)
  @aliases = @aliases.deep_dup
  @options = @options.deep_dup
  @fallbacks = @fallbacks.deep_dup
  @templates = @templates.dup
end