Sha256: 873ed5a250ab5cb90e3cc672073dc5eb770745ba2e6cc81c45c93d7522716a05
Contents?: true
Size: 813 Bytes
Versions: 16
Compression:
Stored size: 813 Bytes
Contents
class Module def module_attribute(*attribute_names, &block) attribute_names.each do |_attribute_name| singleton_class.__send__("attr_accessor", _attribute_name) instance_variable_set("@#{_attribute_name}", block.call) if block_given? end end def recursively_define_namespaced_class(class_name, class_to_inherit_from = Object) paths = class_name.split("::") const_name = paths.shift if paths.length > 0 self.const_set(const_name, ::Module.new) unless self.constants.include?(:"#{const_name}") "#{self.name}::#{const_name}".safe_constantize.recursively_define_namespaced_class(paths.join("::"), class_to_inherit_from) else self.const_set(const_name, ::Class.new(class_to_inherit_from)) unless self.constants.include?(:"#{const_name}") end end end
Version data entries
16 entries across 16 versions & 1 rubygems