Module: Themes::Environments

Included in:
NewGenerator::Environments
Defined in:
lib/themes/environments.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *arguments, &block) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/themes/environments.rb', line 9

def method_missing(method_name, *arguments, &block)
  if block_given? && list.include?(method_name)
    block.call if Rails.env.send("#{method_name}?")
  else
    super
  end
end

Instance Method Details

#listObject



3
4
5
6
7
# File 'lib/themes/environments.rb', line 3

def list
  @list ||= Dir.entries(Rails.root.join('config', 'environments').to_s).
    select{ |f| f.match /.*\.rb/ }.
      map{|f| File.basename(f, '.rb').to_sym}.sort
end