Module: Rounders::Plugins::Pluggable::ClassMethods

Defined in:
lib/rounders/plugins/pluggable.rb

Instance Method Summary collapse

Instance Method Details

#directory_nameObject



23
24
25
# File 'lib/rounders/plugins/pluggable.rb', line 23

def directory_name
  @directory_name ||= Util.infrect(feature_name).pluralize
end

#feature_nameObject



13
14
15
16
17
18
19
20
21
# File 'lib/rounders/plugins/pluggable.rb', line 13

def feature_name
  @feature_name ||= begin
    name_spaces = name.to_s.split('::')
    class_name = name_spaces.last
    module_name = Rounders::Util.infrect(name_spaces[-2]).singularize.classify
    class_name.sub!(/#{module_name}$/, '')
    Rounders::Util.infrect(class_name).underscore
  end
end

#load_pathObject



27
28
29
# File 'lib/rounders/plugins/pluggable.rb', line 27

def load_path
  @load_path ||= File.join(Rounders::APP_PATH, directory_name)
end

#load_pluginsObject



31
32
33
34
35
36
37
38
39
40
# File 'lib/rounders/plugins/pluggable.rb', line 31

def load_plugins
  Pathname.glob("#{load_path}/*.rb").each do |plugin|
    begin
      puts "load #{plugin.expand_path}"
      require_relative plugin.expand_path
    rescue => e
      puts e
    end
  end
end