Class: Dependency

Inherits:
Array
  • Object
show all
Defined in:
lib/javascript_auto_include/dependency.rb

Instance Method Summary collapse

Instance Method Details

#<<(obj) ⇒ Object

Override inherited << method to only add existing files



4
5
6
7
8
9
10
11
# File 'lib/javascript_auto_include/dependency.rb', line 4

def << obj
  if File.exists?("#{::Rails.root}#{File::SEPARATOR}public#{File::SEPARATOR}javascripts#{File::SEPARATOR}#{obj}") || File.exists?("#{::Rails.root}#{File::SEPARATOR}public#{File::SEPARATOR}javascripts#{File::SEPARATOR}#{obj}.js")
    super(obj)
  else
    ::Rails.logger.warn "'#{obj}' wasn't found in '#{::Rails.root}#{File::SEPARATOR}public#{File::SEPARATOR}javascripts' but seems to be required. Your app might not work as expected."
    self
  end
end