Class: Onuro::ContextBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/onuro/context_builder.rb

Overview

Builder class that allows to create a builder pattern for easily creation of the Onuro::Context containing attributes to help you in the event rule processing

See Also:

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeContextBuilder

Creates a new instance of Onuro::ContextBuilder with its Onuro::Context attribute set to default values.

See Also:



15
16
17
# File 'lib/onuro/context_builder.rb', line 15

def initialize
  self.context = Context.new
end

Instance Attribute Details

#contextObject

Onuro::Context generated by the Onuro::ContextBuilder



9
10
11
# File 'lib/onuro/context_builder.rb', line 9

def context
  @context
end

Class Method Details

.build {|builder| ... } ⇒ Object

Class method that uses the builder pattern in order to easy create an Onuro::Context instance and being populated

Yields:

  • (builder)

See Also:



38
39
40
41
42
# File 'lib/onuro/context_builder.rb', line 38

def self.build
  builder = new
  yield builder if block_given?
  builder.context
end

Instance Method Details

#add(key, value) ⇒ Object

Adds a key/value item in the Onuro::Context

See Also:



25
26
27
# File 'lib/onuro/context_builder.rb', line 25

def add(key, value)
  context.add(key, value)
end