Module: Requirium
- Defined in:
- lib/requirium.rb
Overview
Automatically calls Kernel#load or Kernel#require on first use. Example usage:
module M
extend Requirium
autoload :A
autoload :B, 'b', 'b1', 'b2'
autoload A: nil, B: ['b', 'b1', 'b2']
autoload_relative :X
autoload_relative :Y, 'y', 'y1', 'y2'
autoload_relative X: nil, Y: ['y', 'y1', 'y2']
autorequire :A
autorequire :B, 'b', 'b1', 'b2'
autorequire A: nil, B: ['b', 'b1', 'b2']
autorequire_relative :X
autorequire_relative :Y, 'y', 'y1', 'y2'
autorequire_relative X: nil, Y: ['y', 'y1', 'y2']
end
Defined Under Namespace
Classes: Info
Constant Summary collapse
- VERSION =
'0.0.2'.freeze
Class Attribute Summary collapse
-
.loader_thread ⇒ Object
readonly
Returns the value of attribute loader_thread.
-
.queue ⇒ Object
readonly
Returns the value of attribute queue.
Instance Method Summary collapse
-
#autoload(*args) ⇒ Object
TODO sync const_defined? ?.
-
#autoload_relative(*args) ⇒ Object
TODO sync const_defined? ?.
-
#autorequire(*args) ⇒ Object
TODO sync const_defined? ?.
-
#autorequire_relative(*args) ⇒ Object
TODO sync const_defined? ?.
-
#const_missing(sym) ⇒ Object
def const_defined?(*args) Requirium.synchronize { super } end.
Class Attribute Details
.loader_thread ⇒ Object (readonly)
Returns the value of attribute loader_thread.
72 73 74 |
# File 'lib/requirium.rb', line 72 def loader_thread @loader_thread end |
.queue ⇒ Object (readonly)
Returns the value of attribute queue.
72 73 74 |
# File 'lib/requirium.rb', line 72 def queue @queue end |
Instance Method Details
#autoload(*args) ⇒ Object
TODO sync const_defined? ?
75 76 77 |
# File 'lib/requirium.rb', line 75 def autoload(*args) #TODO sync const_defined? ? common_auto :load, args end |
#autoload_relative(*args) ⇒ Object
TODO sync const_defined? ?
79 80 81 |
# File 'lib/requirium.rb', line 79 def autoload_relative(*args) #TODO sync const_defined? ? common_auto :load, args, File.dirname(caller(1, 1)[0][/^(.+):\d+:in `.+'$/, 1]) end |
#autorequire(*args) ⇒ Object
TODO sync const_defined? ?
83 84 85 |
# File 'lib/requirium.rb', line 83 def autorequire(*args) #TODO sync const_defined? ? common_auto :require, args end |
#autorequire_relative(*args) ⇒ Object
TODO sync const_defined? ?
87 88 89 |
# File 'lib/requirium.rb', line 87 def autorequire_relative(*args) #TODO sync const_defined? ? common_auto :require, args, File.dirname(caller(1, 1)[0][/^(.+):\d+:in `.+'$/, 1]) end |