Class: Filament::ExecutionContext
- Inherits:
-
Object
- Object
- Filament::ExecutionContext
- Defined in:
- lib/filament/context.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#wrapper ⇒ Object
readonly
Returns the value of attribute wrapper.
Instance Method Summary collapse
- #execute(&block) ⇒ Object
-
#initialize(package) ⇒ ExecutionContext
constructor
A new instance of ExecutionContext.
- #wrap(*args, &block) ⇒ Object
Constructor Details
#initialize(package) ⇒ ExecutionContext
Returns a new instance of ExecutionContext.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/filament/context.rb', line 8 def initialize(package) @package = package raise "package cannot be nil" if @package.nil? @context = {} @context[:context] = self @context[:this_package] = @package @context[:package_resolver] = @package.package_resolver @context[:target_resolver] = @package.target_resolver end |
Instance Attribute Details
#wrapper ⇒ Object (readonly)
Returns the value of attribute wrapper.
6 7 8 |
# File 'lib/filament/context.rb', line 6 def wrapper @wrapper end |
Instance Method Details
#execute(&block) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/filament/context.rb', line 26 def execute(&block) $context ||= Hash.new {|hash, key| raise "unknown context variable: #{key}"} _context = $context.clone $context.merge!(@context) FileUtils.cd(@package.pathname, &block) $context = _context end |
#wrap(*args, &block) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/filament/context.rb', line 19 def wrap(*args, &block) execute do wrapper = Module.new wrapper.instance_eval(*args, &block) end end |