Module: Idcf::Cli::Controller::Extend::SearchModule
- Included in:
- Init
- Defined in:
- lib/idcf/cli/controller/extend/search_module.rb
Overview
model class search
Instance Method Summary collapse
-
#add_classify_rule ⇒ Object
add classify rule.
- #make_model_name ⇒ Object
-
#make_module_classes ⇒ Object
make module require and class list.
-
#make_service_paths ⇒ Object
make service paths.
-
#search_module_class(module_name) ⇒ Object
search module class.
Instance Method Details
#add_classify_rule ⇒ Object
add classify rule
36 37 38 39 40 41 42 |
# File 'lib/idcf/cli/controller/extend/search_module.rb', line 36 def add_classify_rule Idcf::Cli::Conf::Const::CLASSIFY_RULE.each do |rule| ActiveSupport::Inflector.inflections do |inflect| inflect.irregular(*rule) end end end |
#make_model_name ⇒ Object
59 60 61 62 63 |
# File 'lib/idcf/cli/controller/extend/search_module.rb', line 59 def make_model_name list = to_s.split('::') list.shift(3) list.join('/').underscore end |
#make_module_classes ⇒ Object
make module require and class list
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/idcf/cli/controller/extend/search_module.rb', line 22 def make_module_classes return @m_classes if @m_classes result = {} add_classify_rule make_service_paths.each do |fn, path| require path result[fn] = path.classify.constantize end @m_classes = result end |
#make_service_paths ⇒ Object
make service paths
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/idcf/cli/controller/extend/search_module.rb', line 47 def make_service_paths s_name = make_model_name base_path = Idcf::Cli::Conf::Const::BASE_PATH s_path = "#{Idcf::Cli::Conf::Const::SERVICE_PATH}/#{s_name}" {}.tap do |result| Dir.glob("#{base_path}/#{s_path}/*.rb").each do |f| fn = File.basename(f, '.rb') result[fn] = "#{s_path}/#{fn}" unless fn =~ /^base_*/ end end end |
#search_module_class(module_name) ⇒ Object
search module class
12 13 14 15 16 17 |
# File 'lib/idcf/cli/controller/extend/search_module.rb', line 12 def search_module_class(module_name) make_module_classes.each do |k, v| return v if module_name.to_s == k end nil end |