Class: Charyf::Configuration::Generators

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

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGenerators

Returns a new instance of Generators.



8
9
10
11
# File 'lib/charyf/utils/configuration.rb', line 8

def initialize
  @hidden_namespaces = []
  @options = Hash.new { |h, k| h[k] = {} }
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/charyf/utils/configuration.rb', line 17

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

  return @options[method] if args.empty?

  if method == :charyf || 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[:charyf][method] = namespace
  end

  if configuration
    @options[namespace].merge!(configuration)
  end
end

Instance Attribute Details

#hidden_namespacesObject (readonly)

Returns the value of attribute hidden_namespaces.



6
7
8
# File 'lib/charyf/utils/configuration.rb', line 6

def hidden_namespaces
  @hidden_namespaces
end

#optionsObject

Returns the value of attribute options.



5
6
7
# File 'lib/charyf/utils/configuration.rb', line 5

def options
  @options
end

Instance Method Details

#hide_namespace(namespace) ⇒ Object



13
14
15
# File 'lib/charyf/utils/configuration.rb', line 13

def hide_namespace(namespace)
  @hidden_namespaces << namespace
end