Module: Boc
- Defined in:
- lib/boc.rb,
lib/boc/version.rb,
ext/boc/boc.c
Defined Under Namespace
Classes: AlreadyEnabledError, NotEnabledError
Constant Summary collapse
- MODULE_EVAL =
:nodoc:
Module.instance_method(:module_eval)
- VERSION =
"0.4.2"
Class Method Summary collapse
-
.check_enabled(klass, method_name, impl) ⇒ Object
:nodoc:.
- .enable_basic_object_ext(klass, method_sym) ⇒ Object
- .enable_ext(klass, method_sym) ⇒ Object
-
.no_warn ⇒ Object
squelch alias warnings.
-
.stack ⇒ Object
:nodoc:.
-
.value ⇒ Object
Returns the binding of the caller.
-
.visibility(klass, method_name) ⇒ Object
:nodoc:.
Class Method Details
.check_enabled(klass, method_name, impl) ⇒ Object
:nodoc:
98 99 100 101 102 103 104 |
# File 'lib/boc.rb', line 98 def check_enabled(klass, method_name, impl) #:nodoc: if klass.method_defined?(impl) or klass.private_method_defined?(impl) raise AlreadyEnabledError, "Boc.enable: refusing to overwrite `#{impl}' -- " << "method `#{method_name}' appears to be already enabled" end end |
.enable_basic_object_ext(klass, method_sym) ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'ext/boc/boc.c', line 106 static VALUE enable_basic_object_ext( VALUE self, VALUE klass, VALUE method_sym ) { basic_object_method_sym = method_sym ; rb_define_method( klass, RSTRING_PTR(rb_sym_to_s(method_sym)), dispatch_basic_object, -1) ; return Qnil ; } |
.enable_ext(klass, method_sym) ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 |
# File 'ext/boc/boc.c', line 94 static VALUE enable_ext( VALUE self, VALUE klass, VALUE method_sym ) { rb_define_method( klass, RSTRING_PTR(rb_sym_to_s(method_sym)), dispatch_normal, -1) ; return Qnil ; } |
.no_warn ⇒ Object
squelch alias warnings
78 79 80 81 82 83 84 85 86 |
# File 'lib/boc.rb', line 78 def no_warn #:nodoc: prev = $VERBOSE $VERBOSE = nil begin yield ensure $VERBOSE = prev end end |
.stack ⇒ Object
:nodoc:
71 72 73 |
# File 'lib/boc.rb', line 71 def stack #:nodoc: Thread.current[:_boc_stack] ||= [] end |
.value ⇒ Object
Returns the binding of the caller. May only be used within an enabled method.
47 48 49 50 51 52 |
# File 'lib/boc.rb', line 47 def value if stack.empty? raise NotEnabledError, "Boc.value called outside of an enabled method" end stack.last end |
.visibility(klass, method_name) ⇒ Object
:nodoc:
88 89 90 91 92 93 94 95 96 |
# File 'lib/boc.rb', line 88 def visibility(klass, method_name) #:nodoc: if klass.public_instance_methods.include?(method_name) :public elsif klass.protected_instance_methods.include?(method_name) :protected else :private end end |