Sha256: 450308ece410d0f2cefa52f4f1b9470aa0b2119ed7151be97f7de5e20a0ea497
Contents?: true
Size: 1.16 KB
Versions: 3
Compression:
Stored size: 1.16 KB
Contents
# frozen_string_literal: true require "pakyow/support/extension" require "pakyow/loader" module Pakyow module Behavior # Maintains known aspects and loads them. # module Aspects extend Support::Extension apply_extension do setting :aspects, [] after "load" do config.aspects.each do |aspect| load_aspect(aspect) end end end class_methods do # Registers an app aspect by name. # def aspect(name) (config.aspects << name.to_sym).uniq! end end private def load_aspect(aspect, path: File.join(config.src, aspect.to_s), target: self.class) __load_aspect(aspect, path: path, target: target) end def __load_aspect(aspect, path: File.join(config.src, aspect.to_s), target: self.class) Dir.glob(File.join(path, "*.rb")) do |file_path| Loader.new(file_path).call(target) end Dir.glob(File.join(path, "*")).select { |sub_path| File.directory?(sub_path) }.each do |directory| __load_aspect(aspect, path: directory, target: target) end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
pakyow-core-1.0.0.rc5 | lib/pakyow/behavior/aspects.rb |
pakyow-core-1.0.0.rc4 | lib/pakyow/behavior/aspects.rb |
pakyow-core-1.0.0.rc3 | lib/pakyow/behavior/aspects.rb |