Class: Evil::Plugin::Base
Instance Attribute Summary collapse
-
#configurator ⇒ Object
readonly
Returns the value of attribute configurator.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #config ⇒ Object
- #configure {|@configurator| ... } ⇒ Object
- #description(desc = nil) ⇒ Object
- #filter(fname, &block) ⇒ Object
- #http ⇒ Object
- #init ⇒ Object
-
#initialize(name, &block) ⇒ Base
constructor
A new instance of Base.
- #setup(&block) ⇒ Object
- #tag(name, options = {}, &block) ⇒ Object
Constructor Details
#initialize(name, &block) ⇒ Base
Returns a new instance of Base.
6 7 8 9 10 |
# File 'lib/evil/plugin/base.rb', line 6 def initialize(name, &block) @name = name @configurator = Configuration::Configurator.new block.call(self) end |
Instance Attribute Details
#configurator ⇒ Object (readonly)
Returns the value of attribute configurator.
4 5 6 |
# File 'lib/evil/plugin/base.rb', line 4 def configurator @configurator end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/evil/plugin/base.rb', line 4 def name @name end |
Instance Method Details
#config ⇒ Object
50 51 52 |
# File 'lib/evil/plugin/base.rb', line 50 def config @config ||= Configuration::Config.new(self) end |
#configure {|@configurator| ... } ⇒ Object
46 47 48 |
# File 'lib/evil/plugin/base.rb', line 46 def configure yield @configurator end |
#description(desc = nil) ⇒ Object
16 17 18 19 |
# File 'lib/evil/plugin/base.rb', line 16 def description(desc=nil) @description = desc if desc @description end |
#filter(fname, &block) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/evil/plugin/base.rb', line 30 def filter(fname, &block) mod = Module.new do define_method(fname, &block) end mod.module_eval "def self.name; \"_filter_#{fname}\"; end" Liquid::Template.register_filter(mod) end |
#http ⇒ Object
40 41 42 43 44 |
# File 'lib/evil/plugin/base.rb', line 40 def http @http ||= Module.new do include HTTParty end end |
#init ⇒ Object
12 13 14 |
# File 'lib/evil/plugin/base.rb', line 12 def init @setup_proc.call if @setup_proc end |
#setup(&block) ⇒ Object
21 22 23 |
# File 'lib/evil/plugin/base.rb', line 21 def setup(&block) @setup_proc = block end |
#tag(name, options = {}, &block) ⇒ Object
25 26 27 28 |
# File 'lib/evil/plugin/base.rb', line 25 def tag(name, ={}, &block) tag = [:block] ? BlockTag.from(&block) : SingletonTag.from(&block) Liquid::Template.register_tag(name, tag) end |