Class: Mwc::Environment Private

Inherits:
Object
  • Object
show all
Defined in:
lib/mwc/environment.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

The compile environment manager

Since:

  • 0.3.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent = nil, &block) ⇒ Environment

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Environment.

Since:

  • 0.3.0



18
19
20
21
22
23
24
# File 'lib/mwc/environment.rb', line 18

def initialize(parent = nil, &block)
  @parent = parent
  @environments = {}
  @project = Options::Project.new(parent&.project)
  @mruby = Options::MRuby.new(parent&.mruby)
  instance_exec(self, &block) if block_given?
end

Instance Attribute Details

#environmentsObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.3.0



14
15
16
# File 'lib/mwc/environment.rb', line 14

def environments
  @environments
end

#mrubyObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.3.0



14
15
16
# File 'lib/mwc/environment.rb', line 14

def mruby
  @mruby
end

#projectObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.3.0



14
15
16
# File 'lib/mwc/environment.rb', line 14

def project
  @project
end

Instance Method Details

#env(name, &block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Define new environment

Parameters:

  • name (Symbol)

    the environment name

  • block (Proc)

    the environment config block

Since:

  • 0.3.0



33
34
35
36
37
# File 'lib/mwc/environment.rb', line 33

def env(name, &block)
  return if @parent

  @environments[name.to_sym] = Environment.new(self, &block)
end