Sha256: ed68cef34c7163b25381e6f4196174aeff5cbfaa271656b61120a6307ba69b3c

Contents?: true

Size: 931 Bytes

Versions: 4

Compression:

Stored size: 931 Bytes

Contents

module Legion
  module Extensions
    module Builder
      module Base
        def find_files(name, path = extension_path)
          files = []
          return files unless Dir.exist? "#{path}/#{name}"

          Dir["#{path}/#{name}/*.rb"].each do |file|
            files.push(file)
          end
          files
        end

        def require_files(files)
          files.each { |file| require file }
        end

        def const_defined_two?(item, root = Kernel)
          root.const_defined?(item.to_s)
        end

        def define_constant_two(item, root: Kernel, type: Module)
          return true if root.const_defined?(item)

          root.const_set(item.to_s, type.new)
        end

        def define_get(item, root: Kernel, type: Module)
          define_constant_two(item, root: root, type: type) if const_defined_two?(item, root: root)
          root.const_get(item)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
legionio-1.2.1 lib/legion/extensions/builders/base.rb
legionio-1.2.0 lib/legion/extensions/builders/base.rb
legionio-0.4.3 lib/legion/extensions/builders/base.rb
legionio-0.4.2 lib/legion/extensions/builders/base.rb