Module: Erector::Externals::ClassMethods

Defined in:
lib/erector/externals.rb

Instance Method Summary collapse

Instance Method Details

#dependencies(type) ⇒ Object

returns all dependencies of the given type from this class and all its superclasses



37
38
39
40
41
42
43
# File 'lib/erector/externals.rb', line 37

def dependencies(type)
  type = type.to_sym
  deps = Dependencies.new
  deps.push(*superclass.dependencies(type)) if superclass.respond_to?(:dependencies)
  deps.push(*my_dependencies.select { |x| x.type == type })
  deps.uniq
end

#depends_on(*args) ⇒ Object

Express a dependency of this widget Multiple forms:

depends_on(type, text, options = {})

for example

depends_on(:js, '/foo.js', :embed=>true)

Other variants:

depends_on(type, an_io, ... # file to be read
depends_on('blah.js' ... infer :js
depends_on('blah.css' ... infer :css
depends on :js, 'file1.js', 'file2.js'... [options]
depends_on :js => ["foo.js", "bar.js"], :css=>['file.css']
depends_on :js => ["foo.js", "bar.js"], other_option=>:blah


22
23
24
25
# File 'lib/erector/externals.rb', line 22

def depends_on(*args)
  x = interpret_args(*args)
  my_dependencies.push(x)
end

#external(type, value, options = {}) ⇒ Object

deprecated in favor of #depends_on todo: warning



29
30
31
32
33
# File 'lib/erector/externals.rb', line 29

def external(type, value, options = {})
  type = type.to_sym
  x = Dependency.new(type, value, options)
  my_dependencies << x unless my_dependencies.include?(x)
end

#my_dependenciesObject



45
46
47
# File 'lib/erector/externals.rb', line 45

def my_dependencies
  @my_dependencies ||= Dependencies.new
end