Class: Blur::Extension

Inherits:
Object
  • Object
show all
Includes:
Evaluable, Script::DSL, Logging
Defined in:
library/blur/extension.rb

Overview

Extension provides a sort of modules for scripts, for common functionality.

Think of it as a kind of scripts for scripts.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Script::DSL

#Author, #Description, #Version, #author, #description, included, #name, #version

Methods included from Evaluable

#evaluate_source_file

Constructor Details

#initialize(path) ⇒ Extension

Instantiates a new extension context and evaluates the path extension file.



20
21
22
23
24
25
26
# File 'library/blur/extension.rb', line 20

def initialize path
  @__path = path

  if evaluate_source_file path
    log.info "Loaded extension #{@__path}"
  end
end

Instance Attribute Details

#__clientNetwork::Client

Can be used inside the script to act with the client itself.

Returns:

  • (Network::Client)

    the client delegate.



16
17
18
# File 'library/blur/extension.rb', line 16

def __client
  @__client
end

#__pathObject

Returns the path in which the script remains.

Returns:

  • the path in which the script remains.



13
14
15
# File 'library/blur/extension.rb', line 13

def __path
  @__path
end

Instance Method Details

#Extension(name, &block) ⇒ Object

Purely for DSL purposes.

Examples:

Extension :http do
  
end


34
35
36
37
38
39
40
# File 'library/blur/extension.rb', line 34

def Extension name, &block
  @__name = name
  
  instance_eval &block
  
  true
end