Module: Nanoboy
- Defined in:
- lib/nanoboy.rb,
lib/nanoboy/hook.rb,
lib/nanoboy/version.rb
Defined Under Namespace
Class Attribute Summary collapse
-
.extensions ⇒ Object
Returns the value of attribute extensions.
-
.methods ⇒ Object
Returns the value of attribute methods.
Class Method Summary collapse
- .enable ⇒ Object
-
.extensions_for(sym) ⇒ Object
Returns a Module that, when included, will provide all the scheduled funcionality for
sym
. -
.has_extensions?(sym) ⇒ Boolean
Returns true if the
sym
class has scheduled extensions to be included. - .load_extensions_for(klass, recipient = klass) ⇒ Object
- .version ⇒ Object
Class Attribute Details
.extensions ⇒ Object
Returns the value of attribute extensions.
5 6 7 |
# File 'lib/nanoboy.rb', line 5 def extensions @extensions end |
.methods ⇒ Object
Returns the value of attribute methods.
5 6 7 |
# File 'lib/nanoboy.rb', line 5 def methods @methods end |
Class Method Details
.enable ⇒ Object
56 57 58 |
# File 'lib/nanoboy.rb', line 56 def self.enable Nanoboy::Hook.activate end |
.extensions_for(sym) ⇒ Object
Returns a Module that, when included, will provide all the scheduled funcionality for sym
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/nanoboy.rb', line 17 def self.extensions_for(sym) Module.new{ block = ::Proc.new{|recipient| Nanoboy.methods.each do |method| Array(Nanoboy.extensions[sym.to_s][method]).each do |k| recipient.send(method, k) end end } define_method :included, block module_function :included } end |
.has_extensions?(sym) ⇒ Boolean
Returns true if the sym
class has scheduled extensions to be included
12 13 14 |
# File 'lib/nanoboy.rb', line 12 def self.has_extensions?(sym) extensions[sym.to_s] end |
.load_extensions_for(klass, recipient = klass) ⇒ Object
31 32 33 34 35 |
# File 'lib/nanoboy.rb', line 31 def self.load_extensions_for klass, recipient = klass if has_extensions?(klass.name) recipient.send :include, extensions_for(klass.name) end end |