Method: Deku::Component#initialize

Defined in:
lib/deku/component.rb

#initialize(context, name, source) ⇒ Component

Returns a new instance of Component.

Parameters:

  • context (Deku::Context)

    context to use for instantiating

  • name (String)

    name of the component

  • source (String)

    source of the component



6
7
8
9
10
11
12
13
14
15
# File 'lib/deku/component.rb', line 6

def initialize context, name, source
  @context = context; @name = name; @source = source

  loader_source = create_loader source
  loader_func   = @context.env.runtime.eval(loader_source, name)
  # Create a module for this source
  @mod = CommonJS::Module.new name, @context.env
  # Call the loading function with the module
  loader_func.call(@mod, @mod.require_function, @mod.exports)
end