diff options
| author | Ralph Desir(Mav7) <[email protected]> | 2015-10-14 02:50:12 -0400 |
|---|---|---|
| committer | Ralph Desir(Mav7) <[email protected]> | 2015-10-14 02:50:12 -0400 |
| commit | a5b416e2ce31f28ec4c588b3bc1d0b0567faf7ba (patch) | |
| tree | 657a21c74735eb62237c0a02891b291bf3343b52 /include | |
| parent | 6276227e70753a1f7462fd8b6dfb1d29f36f0e88 (diff) | |
| download | mruby-a5b416e2ce31f28ec4c588b3bc1d0b0567faf7ba.tar.gz mruby-a5b416e2ce31f28ec4c588b3bc1d0b0567faf7ba.zip | |
Added documentation for mrb_undef_method
Diffstat (limited to 'include')
| -rw-r--r-- | include/mruby.h | 63 |
1 files changed, 61 insertions, 2 deletions
diff --git a/include/mruby.h b/include/mruby.h index fd64a07ec..2288f9546 100644 --- a/include/mruby.h +++ b/include/mruby.h @@ -243,8 +243,8 @@ MRB_API mrb_value mrb_singleton_class(mrb_state*, mrb_value); * Include a module in another class or module. * Equivalent to: * - * module B * - * include A * + * module B + * include A * end * @param mrb_state* The current mruby state. * @param RClass* A reference to module or a class. @@ -348,6 +348,65 @@ MRB_API void mrb_define_module_function(mrb_state*, struct RClass*, const char*, * @param mrb_value The value for the constant. */ MRB_API void mrb_define_const(mrb_state*, struct RClass*, const char *name, mrb_value); + +/** + * Undefines a method. + * + * # Ruby style + * + * class A + * + * def a + * "a" + * end + * + * end + * + * A.new.a # => a + * + * class B < A + * + * undef_method :a + * + * end + * + * B.new.a # => undefined method 'a' for B (NoMethodError) + * + * // C style + * + * mrb_value + * mrb_a(mrb_state *mrb){ + * + * return mrb_str_new_cstr(mrb, "a"); + * + * } + * + * void + * mrb_example_gem_init(mrb_state* mrb){ + * struct RClass *a; + * struct RClass *b; + * struct RClass *c; + * + * a = mrb_define_class(mrb, "A", mrb->object_class); + * + * mrb_define_method(mrb, a, "a", mrb_a, MRB_ARGS_NONE()); + * + * b = mrb_define_class(mrb, "B", a); + * + * c = mrb_define_class(mrb, "C", b); + * + * mrb_undef_method(mrb, c, "a"); + * + * } + * + * mrb_example_gem_final(mrb_state* mrb){ + * + * } + * + * @param mrb_state* The MRuby state reference. + * @param RClass* A class the method will be undefined from. + * @param constchar* The name of the method to be undefined. + */ MRB_API void mrb_undef_method(mrb_state*, struct RClass*, const char*); MRB_API void mrb_undef_class_method(mrb_state*, struct RClass*, const char*); |
