Class: Dagger::Generator

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/dagger/generator.rb

Overview

Abstract super class for default value generators. Stores the Context on initialization, and provides private helper methods to concrete subclasses.

Context key access: :call-seq:

dictionary => Hash-like with current key lookup dictionary.

Context value update: :call-seq:

update(key: value, ...)

Stop the processing of current rule chain: :call-seq:

stop

Wrap non-enumerable objects in an Array :call-seq:

enumerable(value) => value || [value]

Concrete subclasses must implement: :call-seq:

process(arg, &->(value))
arg

Value for current method in the rule_chain

value

If a value was found it should be yield:ed

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ Generator

Returns a new instance of Generator.



39
40
41
# File 'lib/dagger/generator.rb', line 39

def initialize(context)
  @context = context
end

Class Method Details

.[](context, arg, &result_yielder) ⇒ Object



35
36
37
# File 'lib/dagger/generator.rb', line 35

def self.[](context, arg, &result_yielder)
  new(context).process(arg, &result_yielder)
end