Module: RedminePluginsHelper::Patches::Redmine::PluginPatch::ClassMethods
- Defined in:
- lib/redmine_plugins_helper/patches/redmine/plugin_patch.rb
Instance Method Summary collapse
- #by_path(path) ⇒ Object
- #plugin_id_from_path(path) ⇒ Object
- #post_register(plugin_name, &block) ⇒ Object
Instance Method Details
#by_path(path) ⇒ Object
19 20 21 22 23 |
# File 'lib/redmine_plugins_helper/patches/redmine/plugin_patch.rb', line 19 def by_path(path) plugin_id_from_path(path).if_present do |v| registered_plugins[v] end end |
#plugin_id_from_path(path) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/redmine_plugins_helper/patches/redmine/plugin_patch.rb', line 25 def plugin_id_from_path(path) path = path.to_pathname. return nil unless path.to_path.start_with?(::Rails.root.to_path) parts = path.relative_path_from(::Rails.root).each_filename.to_a return nil unless parts.first == 'plugins' && parts.count >= 2 parts[1].to_sym end |
#post_register(plugin_name, &block) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/redmine_plugins_helper/patches/redmine/plugin_patch.rb', line 35 def post_register(plugin_name, &block) plugin = registered_plugins[plugin_name] raise "Plugin not registered: #{plugin_name}" unless plugin plugin.instance_eval(&block) end |