Module: Kernel

Defined in:
lib/modulation/ext.rb,
lib/modulation/gem.rb

Overview

Kernel extensions - mock up the Modulation API with nop methods, so requiring a gem would work. Sample usage:

require 'modulation/gem'
export_default :MyGem

module MyGem
  MyClass = import('my_class')
  MyOtherClass = import('my_other_class')
end

Constant Summary collapse

CALLER_RANGE =
(1..1).freeze

Instance Method Summary collapse

Instance Method Details

#auto_import_map(path, options = {}, caller_location = caller(CALLER_RANGE).first) ⇒ Object



33
34
35
36
# File 'lib/modulation/ext.rb', line 33

def auto_import_map(path, options = {},
                    caller_location = caller(CALLER_RANGE).first)
  Modulation.auto_import_map(path, options, caller_location)
end

#export(*args) ⇒ Object

Stub for export method, does nothing in the context of a required gem



17
# File 'lib/modulation/gem.rb', line 17

def export(*args); end

#export_default(value) ⇒ Object

Stub for export_default method, does nothing in the context of a required gem



21
# File 'lib/modulation/gem.rb', line 21

def export_default(value); end

#import(path, caller_location = caller(CALLER_RANGE).first) ⇒ Module

Imports a module

Parameters:

  • path (String)

    module file name

  • caller_location (String) (defaults to: caller(CALLER_RANGE).first)

    caller location

Returns:



11
12
13
# File 'lib/modulation/ext.rb', line 11

def import(path, caller_location = caller(CALLER_RANGE).first)
  Modulation.import(path, caller_location)
end

#import_all(path, caller_location = caller(CALLER_RANGE).first) ⇒ Array

Imports all modules in given directory

Parameters:

  • path (String)

    directory path

  • caller_location (String) (defaults to: caller(CALLER_RANGE).first)

    caller location

Returns:

  • (Array)

    array of module objects



19
20
21
# File 'lib/modulation/ext.rb', line 19

def import_all(path, caller_location = caller(CALLER_RANGE).first)
  Modulation.import_all(path, caller_location)
end

#import_map(path, options = {}, caller_location = caller(CALLER_RANGE).first) ⇒ Hash

Imports all modules in given directory, returning a hash mapping filenames to modules

Parameters:

  • path (String)

    directory path

  • caller_location (String) (defaults to: caller(CALLER_RANGE).first)

    caller location

Returns:

  • (Hash)

    hash mapping filenames to module objects



28
29
30
31
# File 'lib/modulation/ext.rb', line 28

def import_map(path, options = {},
               caller_location = caller(CALLER_RANGE).first)
  Modulation.import_map(path, options, caller_location)
end