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


43
44
45
46
47
48
49
# File 'lib/erector/externals.rb', line 43

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

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

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


35
36
37
38
39
# File 'lib/erector/externals.rb', line 35

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


51
52
53
# File 'lib/erector/externals.rb', line 51

def my_dependencies
  @my_dependencies ||= Dependencies.new
end