class EacRubyUtils::RequireSub
def active_support_require(path)
def active_support_require(path) return false unless options[OPTION_REQUIRE_DEPENDENCY] ::Kernel.require_dependency(path) true end
def apply
def apply require_sub_files include_modules end
def autoload_require(path)
def autoload_require(path) return false unless base? basename = ::File.basename(path, '.*') return false if basename.start_with?('_') base.autoload ::ActiveSupport::Inflector.camelize(basename), path true end
def base
def base options[OPTION_BASE] || raise('Option :base not setted') end
def base?
def base? options[OPTION_BASE] ? true : false end
def include_modules
def include_modules return unless options[OPTION_INCLUDE_MODULES] base.constants.each do |constant_name| constant = base.const_get(constant_name) next unless constant.is_a?(::Module) && !constant.is_a?(::Class) base.include(constant) end end
def initialize(file, options = {})
def initialize(file, options = {}) @file = file @options = self.class.lists.option.hash_keys_validate!(options) end
def kernel_require(path)
def kernel_require(path) ::Kernel.require(path) end
def require_sub_file(path)
def require_sub_file(path) active_support_require(path) || autoload_require(path) || kernel_require(path) end
def require_sub_files
def require_sub_files Dir["#{File.dirname(file)}/#{::File.basename(file, '.*')}/*.rb"].sort.each do |path| require_sub_file(path) end end