Class: EasyE::Plugin
- Inherits:
-
Object
show all
- Defined in:
- lib/easy_e/plugin.rb
Defined Under Namespace
Classes: MongoPlugin, MysqlPlugin
Constant Summary
collapse
- @@registered_plugins =
[]
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Instance Attribute Details
#logger ⇒ Object
Returns the value of attribute logger.
5
6
7
|
# File 'lib/easy_e/plugin.rb', line 5
def logger
@logger
end
|
#options ⇒ Object
Returns the value of attribute options.
5
6
7
|
# File 'lib/easy_e/plugin.rb', line 5
def options
@options
end
|
Class Method Details
.inherited(klass) ⇒ Object
7
8
9
|
# File 'lib/easy_e/plugin.rb', line 7
def self.inherited(klass)
registered_plugins.unshift klass
end
|
.registered_plugins ⇒ Object
11
12
13
|
# File 'lib/easy_e/plugin.rb', line 11
def self.registered_plugins
@@registered_plugins
end
|
Instance Method Details
#carefully(msg) ⇒ Object
39
40
41
42
43
44
45
|
# File 'lib/easy_e/plugin.rb', line 39
def carefully msg
yield
rescue Exception => e
logger.error "Error while trying to #{msg}"
logger.error e
nil
end
|
#collect_options(option_parser) ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/easy_e/plugin.rb', line 27
def collect_options option_parser
option_parser.on "--#{name.downcase}", "Enable the #{name} plugin" do
options.enable = true
end
defined_options.each do |option_name, description|
option_parser.on "--#{name.downcase}-#{option_name.to_s.gsub('_','-')} #{option_name.upcase}", description do |val|
options[option_name.to_sym] = val
end
end
end
|
#default_options ⇒ Object
15
16
17
|
# File 'lib/easy_e/plugin.rb', line 15
def default_options
{ }
end
|