Sha256: ad3f8d67d5057b3c64d94ab3542af9d1c5590535232f469fed13ce92e85e7855
Contents?: true
Size: 1.08 KB
Versions: 14
Compression:
Stored size: 1.08 KB
Contents
module Sandthorn module BoundedContext module ClassMethods def aggregate_types @aggregate_list = p_aggregate_types(self) end private def p_aggregate_types(bounded_context_module) return [] unless bounded_context_module.respond_to?(:constants) classes = classes_in(bounded_context_module) aggregate_list = classes.select { |item| item.include?(Sandthorn::AggregateRoot) } modules = modules_in(bounded_context_module, classes) aggregate_list += modules.flat_map { |m| p_aggregate_types(m) } aggregate_list end def classes_in(namespace) namespace.constants.map(&namespace.method(:const_get)).grep(Class) end def modules_in(namespace, classes) namespace.constants.map(&namespace.method(:const_get)).grep(Module).delete_if do |m| classes.include?(m) || m == Sandthorn::BoundedContext::ClassMethods end end end extend ClassMethods def self.included( other ) other.extend( ClassMethods ) end end end
Version data entries
14 entries across 14 versions & 1 rubygems