class ADSL::Railtie

Public Instance Methods

extract_actions_param_from_args() click to toggle source
# File lib/adsl/railtie.rb, line 16
def extract_actions_param_from_args
  actions     = ("#{extract_arg('ACTION')    },#{extract_arg('ACTIONS')    }").split(',').map(&:strip).reject(&:empty?)
  controllers = ("#{extract_arg('CONTROLLER')},#{extract_arg('CONTROLLERS')}").split(',').map(&:strip).reject(&:empty?)
  if actions.empty? and controllers.empty?
    nil
  elsif actions.empty?
    controllers
  elsif controllers.empty?
    actions
  else
    action_controllers = []
    actions.each do |a|
      controllers.each do |c|
        action_controllers << "#{c}__#{a}"
      end
    end
    action_controllers
  end
end
extract_arg(key) click to toggle source
# File lib/adsl/railtie.rb, line 8
def extract_arg(key)
  regex = /^#{key}\s*=\s*(.+)$/
  ARGV[1..-1].each do |arg|
    return arg.match(regex)[1] if regex =~ arg
  end
  nil
end