Class: Rubuild::Env::Provider

Inherits:
Object
  • Object
show all
Defined in:
lib/rubuild/env/provider.rb

Overview

Provider

Instance Method Summary collapse

Constructor Details

#initialize(env, name) ⇒ Provider

Returns a new instance of Provider.



11
12
13
14
15
16
17
18
19
20
# File 'lib/rubuild/env/provider.rb', line 11

def initialize(env, name)
  self.rubuild_env_provider__env = env
  self.rubuild_env_provider__location = Rubuild::Env::Location.new(name, env.build_factory)
  self.rubuild_env_provider__arglist = Array.new
  self.rubuild_env_provider__exec_dep = env.build_factory.create_dep(
    self.method(:_exec_satisfied), "#{self.class.to_s}.exec(#{name})")
  self.rubuild_env_provider__location.found_dep.add_parent(
    self.rubuild_env_provider__exec_dep)
  env.provide(name, self.rubuild_env_provider__location)
end

Instance Method Details

#_exec_satisfied(dep) ⇒ Object



36
37
38
39
40
41
42
43
44
45
# File 'lib/rubuild/env/provider.rb', line 36

def _exec_satisfied(dep)
  exec_block = self.rubuild_env_provider__exec_block
  self.rubuild_env_provider__exec_block = nil
  block_args = self.rubuild_env_provider__arglist.map do |arg|
    arg.location.data
  end
  self.rubuild_env_provider__arglist = nil
  exec_block.call(self, *block_args)
  self.rubuild_env_provider__location = nil
end

#exec(&block) ⇒ Object



33
34
35
# File 'lib/rubuild/env/provider.rb', line 33

def exec(&block)
  self.rubuild_env_provider__exec_block = block
end

#require(*args) ⇒ Object



22
23
24
25
26
27
# File 'lib/rubuild/env/provider.rb', line 22

def require(*args)
  req = Rubuild::Env::Requirer.new(self.rubuild_env_provider__env, *args)
  self.rubuild_env_provider__arglist << req
  self.rubuild_env_provider__exec_dep.add_parent(req.location.found_dep)
  self
end

#require_(*args) ⇒ Object



28
29
30
31
32
# File 'lib/rubuild/env/provider.rb', line 28

def require_(*args)
  req = Rubuild::Env::Requirer.new(self.rubuild_env_provider__env, *args)
  self.rubuild_env_provider__exec_dep.add_parent(req.location.found_dep)
  self
end

#set(object) ⇒ Object



46
47
48
# File 'lib/rubuild/env/provider.rb', line 46

def set(object)
  self.rubuild_env_provider__location.set_data(object)
end