Sha256: 8813e21eb287487971c47362d1ef344225fd7e41ac1bbcf8b8558c3a66904aca
Contents?: true
Size: 919 Bytes
Versions: 1
Compression:
Stored size: 919 Bytes
Contents
#-*- mode: ruby; coding: utf-8 -*- require 'module_plus/attribute' require 'module_plus/exception' module ModulePlus module Identification def full_name my_klass.to_s end def full_names full_name.split(/::/) end def nest_names full_names.inject([]) do |list, name| list << (list.empty? ? name : "#{list.last}::#{name}") end end def root_name nest_names.first end def outer_names r = nest_names r.take(r.size - 1) end def nests # nest_names.map { |name| eval(name) } # rubocop:disable Security/Eval end def root eval(root_name) # rubocop:disable Security/Eval end def outers outer_names.map { |n| eval(n) } # rubocop:disable Security/Eval end private def my_klass if self.is_a? Module self else self.class end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
module_plus-0.1.0 | lib/module_plus/identification.rb |