Class: Evil::Plugin::Base

Inherits:
Object show all
Defined in:
lib/evil/plugin/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#configuratorObject (readonly)

Returns the value of attribute configurator.



4
5
6
# File 'lib/evil/plugin/base.rb', line 4

def configurator
  @configurator
end

#nameObject (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

#configObject



50
51
52
# File 'lib/evil/plugin/base.rb', line 50

def config
  @config ||= Configuration::Config.new(self)
end

#configure {|@configurator| ... } ⇒ Object

Yields:



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

#httpObject



40
41
42
43
44
# File 'lib/evil/plugin/base.rb', line 40

def http
  @http ||= Module.new do
    include HTTParty
  end
end

#initObject



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, options={}, &block)
  tag = options[:block] ? BlockTag.from(&block) : SingletonTag.from(&block)
  Liquid::Template.register_tag(name, tag)
end