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.



16
17
18
19
20
21
# File 'lib/charyf/utils/configuration.rb', line 16

def initialize
  @hidden_namespaces = []
  @installers = []
  @skill_hooks = []
  @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



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/charyf/utils/configuration.rb', line 27

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.



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

def hidden_namespaces
  @hidden_namespaces
end

#installersObject (readonly)

Returns the value of attribute installers.



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

def installers
  @installers
end

#skill_hooksObject (readonly)

Returns the value of attribute skill_hooks.



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

def skill_hooks
  @skill_hooks
end

Instance Method Details

#hide_namespace(namespace) ⇒ Object



23
24
25
# File 'lib/charyf/utils/configuration.rb', line 23

def hide_namespace(namespace)
  @hidden_namespaces << namespace
end

#optionsObject



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

def options
  dup = @options.dup
  dup[:charyf] ||= {}
  dup[:installers] = @installers
  dup[:skill_hooks] = @skill_hooks

  dup
end