Class: Module

Inherits:
Object show all
Defined in:
lib/rmtools/functional/decorate.rb,
lib/rmtools/core/module.rb

Overview

Emulate python’s @-operator Consider as proof of concept since there is alias_method_chain that rubyists used to use for decorating

Instance Method Summary collapse

Instance Method Details

#childrenObject



15
16
17
# File 'lib/rmtools/core/module.rb', line 15

def children
  constants.map! {|c| module_eval c.to_s}.find_all {|c| c.kinda Module rescue()}
end

#each_childObject



19
20
21
22
# File 'lib/rmtools/core/module.rb', line 19

def each_child
  (cs = constants.map! {|c| module_eval c.to_s}).each {|c| yield c if c.kinda Module}
  cs
end

#my_methods(filter = //) ⇒ Object Also known as: personal_methods



28
29
30
# File 'lib/rmtools/core/module.rb', line 28

def my_methods filter=//
  (self.singleton_methods - Object.singleton_methods).sort!.grep(filter)
end

#remove_possible_method(method) ⇒ Object

rewrite of active suport method to not initialize significant part of NameErrors



7
8
9
10
11
12
13
# File 'lib/rmtools/core/module.rb', line 7

def remove_possible_method(method)
  if method_defined? method
    begin remove_method method
    rescue NameError
    end
  end
end

#self_nameObject



24
25
26
# File 'lib/rmtools/core/module.rb', line 24

def self_name
  @self_name ||= name[/[^:]+$/]
end