Module: Katte::Plugins::Base
Instance Method Summary collapse
- #define_keyword(keyword) ⇒ Object
- #find(index) ⇒ Object
- #included(klass) ⇒ Object
- #index(keyword = nil) ⇒ Object
- #plugins ⇒ Object
- #register(index, plugin) ⇒ Object
Instance Method Details
#define_keyword(keyword) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/katte/plugins/base.rb', line 16 def define_keyword(keyword) klass = self class_methods.send(:define_method, keyword) {|value| define_method(keyword) { value } if klass.index == keyword klass.register(value, self.new) end } end |
#find(index) ⇒ Object
34 35 36 |
# File 'lib/katte/plugins/base.rb', line 34 def find(index) plugins[index] end |
#included(klass) ⇒ Object
8 9 10 |
# File 'lib/katte/plugins/base.rb', line 8 def included(klass) klass.extend class_methods end |
#index(keyword = nil) ⇒ Object
12 13 14 15 |
# File 'lib/katte/plugins/base.rb', line 12 def index(keyword = nil) return @index unless keyword @index = keyword end |
#plugins ⇒ Object
28 29 30 |
# File 'lib/katte/plugins/base.rb', line 28 def plugins @plugins ||= {} end |
#register(index, plugin) ⇒ Object
31 32 33 |
# File 'lib/katte/plugins/base.rb', line 31 def register(index, plugin) plugins[index] = plugin end |