Class: Gitosis::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/gitosis_easy_conf/config.rb

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Config

Returns a new instance of Config.



3
4
5
6
# File 'lib/gitosis_easy_conf/config.rb', line 3

def initialize(&block)
  @configs = {}
  instance_eval(&block)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/gitosis_easy_conf/config.rb', line 8

def method_missing(method, *args, &block)
  if args.length > 0 || block_given?
    @configs[method] = case method
                       when :fork_naming_convention then
                         if block_given? && ![2,-1].include?(block.arity)
                           raise BlockArityIncorrect, "Block needs exactly two arguments"
                         end
                         block
                       when :filename then
                         args.first
                       else
                         [args, block]
                       end
  else
    @configs[method]
  end
end