class Traitee::Dict
Public Class Methods
new()
click to toggle source
# File lib/traitee/dict.rb, line 5 def initialize @methods = Set.new end
Public Instance Methods
<<(method)
click to toggle source
# File lib/traitee/dict.rb, line 9 def <<(method) @methods << method end
aliases(methods, aliases)
click to toggle source
create aliases for selected methods as described in opts
# File lib/traitee/dict.rb, line 30 def aliases(methods, aliases) Hash[methods.map { |method_name, _method| [(aliases.include?(method_name) ? aliases[method_name] : method_name), _method] }] end
exclusions(methods, exclusions)
click to toggle source
fetch only methods on included in except opts
# File lib/traitee/dict.rb, line 25 def exclusions(methods, exclusions) methods.select { |method_name, _| !exclusions.include?(method_name) } end
methods_hash(options = {})
click to toggle source
# File lib/traitee/dict.rb, line 13 def methods_hash(options = {}) except = Array(options[:except]) aliases = options.fetch :aliases, {} methods_hash = Hash[ @methods.map { |method| traitee_module, name = method; [name, traitee_module.instance_method(name)] } ] methods_hash = exclusions(methods_hash, except) aliases(methods_hash, aliases) end