Module: Backhead::ClassMethods

Defined in:
lib/backhead.rb

Instance Method Summary collapse

Instance Method Details

#configuration(name, &block) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/backhead.rb', line 13

def configuration(name, &block)
  options = @_current_configuration_options = Set.new
  yield if block_given?
  struct = Struct.new(*options.to_a).new
  config.send("#{name}=", struct)
  initializer "#{name}.setup" do |app|
    options.each do |option|
      if struct.send(option).nil?
        struct.send("#{option}=", ENV["#{name}_#{option}".upcase])
      end
    end
  end
end

#option(name) ⇒ Object



27
28
29
# File 'lib/backhead.rb', line 27

def option(name)
  @_current_configuration_options << name.to_sym
end