Class: Nenv::Environment

Inherits:
Object
  • Object
show all
Defined in:
lib/nenv/environment.rb,
lib/nenv/environment/dumper.rb,
lib/nenv/environment/loader.rb,
lib/nenv/environment/dumper/default.rb,
lib/nenv/environment/loader/default.rb,
lib/nenv/environment/loader/predicate.rb

Direct Known Subclasses

AutoEnvironment

Defined Under Namespace

Modules: Dumper, Loader Classes: AlreadyExistsError, Error, MethodError

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(namespace = nil) ⇒ Environment

Returns a new instance of Environment.



21
22
23
# File 'lib/nenv/environment.rb', line 21

def initialize(namespace = nil)
  @namespace = (namespace ? namespace.upcase : nil)
end

Class Method Details

._create_env_accessor(klass, meth, &block) ⇒ Object



44
45
46
47
48
49
50
51
52
# File 'lib/nenv/environment.rb', line 44

def _create_env_accessor(klass, meth, &block)
  _fail_if_accessor_exists(klass, meth)

  if meth.to_s.end_with? '='
    _create_env_writer(klass, meth, &block)
  else
    _create_env_reader(klass, meth, &block)
  end
end

.create_method(meth, &block) ⇒ Object



40
41
42
# File 'lib/nenv/environment.rb', line 40

def create_method(meth, &block)
  _create_env_accessor(self, meth, &block)
end

Instance Method Details

#create_method(meth, &block) ⇒ Object



25
26
27
# File 'lib/nenv/environment.rb', line 25

def create_method(meth, &block)
  self.class._create_env_accessor(singleton_class, meth, &block)
end